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
2
3
0
3
3
1
0.197375
0
I have a web service that is required to handle significant concurrent utilization and volume and I need to test it. Since the service is fairly specialized, it does not lend itself well to a typical testing framework. The test would need to simulate multiple clients concurrently posting to a URL, parsing the resulting Http response, checking that a database has been appropriately updated and making sure certain emails have been correctly sent/received. The current opinion at my company is that I should write this framework using Python. I have never used Python with multiple threads before and as I was doing my research I came across the Global Interpreter Lock which seems to be the basis of most of Python's concurrency handling. It seems to me that the GIL would prevent Python from being able to achieve true concurrency even on a multi-processor machine. Is this true? Does this scenario change if I use a compiler to compile Python to native code? Am I just barking up the wrong tree entirely and is Python the wrong tool for this job?
0
python
2010-08-11T12:36:00.000
0
3,458,249
The Global Interpreter Lock prevents threads simultaneously executing Python code. This doesn't change when Python is compiled to bytecode, because the bytecode is still run by the Python interpreter, which will enforce the GIL. threading works by switching threads every sys.getcheckinterval() bytecodes. This doesn't apply to multiprocessing, because it creates multiple Python processes instead of threads. You can have as many of those as your system will support, running truly concurrently. So yes, you can do this with Python, either with threading or multiprocessing.
0
1,336
false
0
1
Concurrency Testing For A Web Service Using Python
3,458,598
1
2
0
4
3
0
1.2
0
I'm looking for the most elegant way to notify users of my library that they need a specific unix command to ensure that it will works... When is the bet time for my lib to raise an error: Installation ? When my app call the command ? At the import of my lib ? both? And also how should you detect that the command is missing (if not commands.getoutput("which CommandIDependsOn"): raise Exception("you need CommandIDependsOn")). I need advices.
0
python,command,packaging,distutils
2010-08-12T06:41:00.000
1
3,465,295
I wouldn't have any check at all. Document that your library requires this command, and if the user tries to use whatever part of your library needs it, an exception will be raised by whatever runs the command. It should still be possible to import your library and use it, even if only a subset of functionality is offered. (PS: commands is old and broken and shouldn't be used in new code. subprocess is the hot new stuff.)
0
629
true
0
1
How to depends of a system command with python/distutils?
3,466,094
1
8
0
0
12
1
0
0
I would like to write a code internal to my method that print which method/class has invoked it. (My assumption is that I can't change anything but my method..) How about other programming languages? EDIT: Thanks guys, how about JavaScript? python? C++?
0
java,javascript,python,programming-languages,classloader
2010-08-12T13:25:00.000
0
3,468,101
In Python, you should use the traceback or inspect modules. These will modules will shield you from the implementation details of the interpreter, which can differ even today (e.g. IronPython, Jython) and may change even more in the future. The way these modules do it under the standard Python interpreter today, however, is with sys._getframe(). In particular, sys._getframe(1).f_code.co_name provides the information you want.
0
754
false
0
1
Java or any other language: Which method/class invoked mine?
3,469,617
2
4
0
2
1
0
1.2
0
I'd like to compare the performance of different languages and/or different frameworks within the same language. This is aimed at server-side languages used for web development. I know an apples to apples comparison is not possible, but I'd like it to be as unbiased as possible. Here are some ideas : Simple "Hello World" page Object initialization Function/method calls Method bodies will range from empty to large File access (read and write) Database access They can either be measured by Requests per second or I can use a for loop and loop many times. Some of these benchmarks should measure the overhead the language has (ie: empty function call) rather than how fast they perform a certain task. I'll take some precautions: They'll run on the same machine, on fresh installations with as few processes on the background as possible. I'll try and set up the server as officially recommended; I will not attempt any optimizations. How can I improve on this?
0
php,asp.net,python,frameworks,benchmarking
2010-08-12T13:37:00.000
0
3,468,227
What I have done is to write many unit tests so you can test the layers. For example, write a SOAP web service in PHP, Python and C#. Write a REST web service in the same languages (same web services, just two ways to get to them). This one should be able to return JSON and XML as a minimum. Write unit tests in C# and Python to serve as clients, and test the REST with the various result types (XML/JSON). This is important as later you may need to test to see which is best end-to-end, and JSON may be faster to parse than XML, for you (it should be). So, the REST/SOAP services should go to the same controller, to simplify your life. This controller needs tests, as you may need to later remove it's impact on your tests, but, you can also write tests to see how fast it goes to the database. I would use one database for this, unless you want to evaluate various databases, but for a web test, just do that for phase 2. :) So, what you end up with is lots of tests, each test needs to be able to determine how long it took for it to actually run. You then have lots of numbers, and you can start to analyze to see what works best for you. For example, I had learned (a couple of years ago when I did this) that JSON was faster than XML, REST was faster than SOAP. You may find that some things are much harder to do in some languages and so drop them from contention as you go through this process. Writing the tests is the easy part, getting meaningful answers from the numbers will be the harder part, as your biases may color your analysis, so be careful of that. I would do this with some real application so that the work isn't wasted, just duplicated.
0
463
true
1
1
How can I benchmark different languages / frameworks?
3,468,630
2
4
0
0
1
0
0
0
I'd like to compare the performance of different languages and/or different frameworks within the same language. This is aimed at server-side languages used for web development. I know an apples to apples comparison is not possible, but I'd like it to be as unbiased as possible. Here are some ideas : Simple "Hello World" page Object initialization Function/method calls Method bodies will range from empty to large File access (read and write) Database access They can either be measured by Requests per second or I can use a for loop and loop many times. Some of these benchmarks should measure the overhead the language has (ie: empty function call) rather than how fast they perform a certain task. I'll take some precautions: They'll run on the same machine, on fresh installations with as few processes on the background as possible. I'll try and set up the server as officially recommended; I will not attempt any optimizations. How can I improve on this?
0
php,asp.net,python,frameworks,benchmarking
2010-08-12T13:37:00.000
0
3,468,227
You will spend a lot of time and come to realization that it was all wasted. After you complete your tests you will learn that loops of 1000000 empty iterations are far from the real life and come to apache benchmark. Then you come no know of opcode cachers which will ruin all your previous results. Then you will learn that single DB query will take 1000 times longer time than API call, so, your comparisons of database access methods are really waste. Then you will learn of memcache which will allow you just jump over some terrible bottlenecks you've discovered already, etc etc etc
0
463
false
1
1
How can I benchmark different languages / frameworks?
3,468,464
2
3
0
9
2
0
1
0
I'm currently using PHP. I plan to start using Django for some of my next project. But I don't have any experience with Python. After some searching, I still can't find a Python opcode cacher. (There are lots of opcode cacher for PHP: APC, eAccelerator, Xcache, ...)
0
python,opcode,opcode-cache
2010-08-12T13:40:00.000
0
3,468,243
It's automatic in Python -- a compiled .pyc file will appear magically.
0
2,395
false
1
1
Python doesn't have opcode cacher?
3,468,276
2
3
0
2
2
0
0.132549
0
I'm currently using PHP. I plan to start using Django for some of my next project. But I don't have any experience with Python. After some searching, I still can't find a Python opcode cacher. (There are lots of opcode cacher for PHP: APC, eAccelerator, Xcache, ...)
0
python,opcode,opcode-cache
2010-08-12T13:40:00.000
0
3,468,243
Python doesn't need one the same way PHP needs it. Python doesn't throw the bytecode away after execution, it keeps it around (as .pyc files).
0
2,395
false
1
1
Python doesn't have opcode cacher?
3,468,296
1
5
0
0
3
0
0
1
Hey all, I have a site that looks up info for the end user, is written in Python, and requires several urlopen commands. As a result it takes a bit for a page to load. I was wondering if there was a way to make it faster? Is there an easy Python way to cache or a way to make the urlopen scripts fun last? The urlopens access the Amazon API to get prices, so the site needs to be somewhat up to date. The only option I can think of is to make a script to make a mySQL db and run it ever now and then, but that would be a nuisance. Thanks!
0
python,sql,caching,urlopen
2010-08-12T13:40:00.000
0
3,468,248
How often do the price(s) change? If they're pretty constant (say once a day, or every hour or so), just go ahead and write a cron script (or equivalent) that retrieves the values and stores it in a database or text file or whatever it is you need. I don't know if you can check the timestamp data from the Amazon API - if they report that sort of thing.
0
805
false
0
1
Caching options in Python or speeding up urlopen
3,468,315
1
7
0
1
49
0
0.028564
0
I have a jpg image. I need to know "overall average" the color of the image. At first glance there can use the histogram of the image (channel RGB). At work I use mostly JavaScript and PHP (a little Python) therefore welcomed the decision in these languages. Maybe ther are library for working with images that address similar problems. I do not need to dynamically determine the color of the picture. I need just once go through the entire array of images and determine the color of each separately (this information I will remember for future use).
0
php,javascript,python,image-processing
2010-08-12T14:02:00.000
0
3,468,500
A shorter solution for true color image would be to scale it down to 1x1 pixel size and sample the color at that pixel: $scaled = imagescale($img, 1, 1, IMG_BICUBIC); $meanColor = imagecolorat($img, 0, 0); ...but I haven't tested this myself.
0
37,896
false
0
1
Detect "overall average" color of the picture
17,615,110
1
2
0
12
7
0
1.2
0
I want to save the MessageID of a sent email, so I can later use it in a References: header to facilitate threading. I see in root/django/trunk/django/core/mail.py (line ~55) where the MessageID is created. I'm trying to think of the best way to collect this value, other than just copy/pasting into a new backend module and returning it. Maybe that is the best way?
0
python,django,email-headers
2010-08-12T18:54:00.000
0
3,470,989
Ok, I see I was browsing tragically old code. I should be able to call django.core.mail.message.make_msgid() and populate the header myself before calling send.
0
2,548
true
1
1
What's the easiest/cleanest way to get the MessageID of a sent email?
3,471,052
1
2
0
3
7
0
0.291313
0
Is anyone aware of a pure python implementation of BLAST alignment? I am trying to study this algorithm...
0
python,alignment,blast
2010-08-13T18:09:00.000
0
3,479,569
In fact a complete implementation of the BLAST algorithm is a quite hard. It has a lot of steps and optimizations. What could you do is: take a look of the BLAST Book from O'Reilly, for a very good explanation, take a look of the NCBI Blast code base, that it is big and hard to understand at the first glace, or, I sugest you to take a look at other BLAST implementation or may be, others algorithms like BLAT and Genoogle (http://genoogle.pih.bio.br/)
0
3,698
false
0
1
Python implementation of BLAST alignment algorithm?
5,816,012
1
1
0
2
2
1
1.2
0
I am using Komodo edit on a Python file on Windows. When I type import s it successfully lists all the importable files starting with s, including one of my modules in one of my directories. When I type import t it lists all the importable files starting with t, EXCLUDING one of my modules in the same directory. Even though Komodo can't find it, the Python interpreter finds and runs both files fine. It is purely a problem with Komodo's Code Intelligence. The name of the missing module is 9 lower-case letters (nothing fancy). It doesn't clash with any other modules. It is in the same directory as the module that can be found. Any suggestions about why one module is found and another isn't?
0
python,komodo,komodoedit
2010-08-14T04:01:00.000
0
3,481,949
Problem solved itself when I closed Komodo, saving the project, and reopened it. Sounds like Komodo's internal representation was out-of-date or corrupted. I'll leave the question here for the next person who stumbles over it.
0
1,865
true
0
1
Komodo Edit auto-complete won't find a Python module
3,482,353
1
7
0
5
5
0
0.141893
0
I'm new to Python, with a background in statically typed languages including lots and lots of Java. I decided on PyDev in eclipse as an IDE after checking features/popularity etc. I was stunned that auto-complete doesn't seem to work properly for builtins. For example if I try automcomplete on datafile after: datafile = open(directory+"/"+account, 'r') datafile. No useful methods are suggested (e.g. realines). Only things like call. I am used to learning a language by jumping into class definitions and using lots of auto-complete to quickly view what a class will do. My PyDev 'interpreter' is set up fine with 'forced builtins'. Is it possible to get auto-complete for builtins with PyDev? Am I approaching the IDE wrong, i.e. should have an interpreter running on the side and test stuff with it? So far the IDEs have seemed weak, e.g. IDLE segfaulted on my new mac after 2 minutes. I'd love to know what experienced Python developers do when exploring unfamiliar (builtin) modules, as this is making me reconsider my initial attraction to Python. I like a language you can learn by easy exploration! Thanks,
0
python,ide,autocomplete,duck-typing,built-in
2010-08-14T08:38:00.000
1
3,482,622
Just to keep it up to date so that new readers are not confused about the current state of Pydev - the example you gave now works in Pydev. (btw, one should avoid operating on paths manualy - use os.path.join instead)
0
3,018
false
0
1
Autocompletion in dynamic language IDEs, specifically Python in PyDev
9,430,038
3
3
0
7
12
0
1
0
Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host? After some quick tinkering, right now I'm leaning towards powershell for two main reasons (note these a purely my opinions and if they are wrong, I'd love to know!!!): 1) It's simple to create a runspace with classes in your application; therefor it's easy to make your application scriptable. 2) I've heard some rumors that IronRuby and IronPython are losing support from Microsoft, so they may be a poor long term solution? As this is my first time adding scripting to an application though, I'd welcome all the advice I can get from people who have been down this road before. Specifically, besides letting me know whether you agree with my two points above, I'd like to know if IronRuby and IronPython are much easier to use (for a user, not developer) than powershell, and if in your experience using the DLR is as easy as just passing an object to a powershell runspace? And if I added support for the DLR and IR/IP scripting would my application still be backwards compatible with XP?
0
c#,powershell,ironpython,ironruby,dynamic-language-runtime
2010-08-14T16:47:00.000
0
3,484,232
number 2 is true (the dynamic lang teams have been losing headcount for awhile now) and an excellent reason. Ruby and Python aren't MS languages, and as such Iron * is just 'get it working on .NET'. PowerShell is a Microsoft creation, Microsoft-controlled, and Microsoft-supported. More importantly, multiple Microsoft products have taken deep dependencies on PowerShell (Exchange, SharePoint, etc.) so there's very little question of PowerShell's ongoing support as a language. Last, PowerShell considers being the scripting lang for other applications as one of its first-class support targets.
0
3,780
false
0
1
Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?
3,484,368
3
3
0
12
12
0
1
0
Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host? After some quick tinkering, right now I'm leaning towards powershell for two main reasons (note these a purely my opinions and if they are wrong, I'd love to know!!!): 1) It's simple to create a runspace with classes in your application; therefor it's easy to make your application scriptable. 2) I've heard some rumors that IronRuby and IronPython are losing support from Microsoft, so they may be a poor long term solution? As this is my first time adding scripting to an application though, I'd welcome all the advice I can get from people who have been down this road before. Specifically, besides letting me know whether you agree with my two points above, I'd like to know if IronRuby and IronPython are much easier to use (for a user, not developer) than powershell, and if in your experience using the DLR is as easy as just passing an object to a powershell runspace? And if I added support for the DLR and IR/IP scripting would my application still be backwards compatible with XP?
0
c#,powershell,ironpython,ironruby,dynamic-language-runtime
2010-08-14T16:47:00.000
0
3,484,232
I'm not convinced PowerShell has "being a scripting language for applications" anywhere in it's long-term goals. It's first a shell, second an integration & automation engine, and third a shell scripting language ... since it's not redistributable at all, I'm not sure where embedded scripting fits in. It's certainly very easy to host PowerShell -- assuming that it's pre-installed on your target PCs-- so it's a very viable option, but I think that in general it's just as easy to do it with IronRuby or IronPython. I doubt the DLR itself is going away, so I think using a DLR language is still a good choice for this: you'd be set up to accept other DLR languages with much less effort, and the DLR and languages are redistributable. Also, the work to host PowerShell only gets you PowerShell -- whereas you can leverage the same work to get IronPython and IronRuby working. Who knows, since PowerShell is a dynamic language, maybe it will be ported to the DLR with proper dynamics support in a future version ... but it's unlikely to ever be redistributable, because Microsoft doesn't consider it a dev tool, but rather a core part of the OS. Bottom line: using the DLR is much more portable -- and not just to XP but even to Mono (and thus to Linux, OS X, iOS, Android, etc... and even to the web or Windows Phone via Silverlight).
0
3,780
false
0
1
Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?
3,496,609
3
3
0
2
12
0
0.132549
0
Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host? After some quick tinkering, right now I'm leaning towards powershell for two main reasons (note these a purely my opinions and if they are wrong, I'd love to know!!!): 1) It's simple to create a runspace with classes in your application; therefor it's easy to make your application scriptable. 2) I've heard some rumors that IronRuby and IronPython are losing support from Microsoft, so they may be a poor long term solution? As this is my first time adding scripting to an application though, I'd welcome all the advice I can get from people who have been down this road before. Specifically, besides letting me know whether you agree with my two points above, I'd like to know if IronRuby and IronPython are much easier to use (for a user, not developer) than powershell, and if in your experience using the DLR is as easy as just passing an object to a powershell runspace? And if I added support for the DLR and IR/IP scripting would my application still be backwards compatible with XP?
0
c#,powershell,ironpython,ironruby,dynamic-language-runtime
2010-08-14T16:47:00.000
0
3,484,232
I'm in a similar position. I decided to use IronPython scripting but ever since I saw Anders Hejlsberg's talk "The Future of C#", I've had a feeling IronPython was doomed. It was in Microsoft's interest to get the DLR developed but they ultimately want us to use tools and languages they control. After all, aren't you using C# and not Java? So what will a Microsoft dynamic language look like? How about dynamic, interpreted C# (Iron C#)? Hejlsberg's talk made it clear it isn't that far away. He even had a console window with a REPL interface. That said, there's always a possibility for Iron VB. Talk about closing the loop. On the plus side for us programmers, Iron C# also solves another problem that I'm having trouble with -- the existence of two parallel object environments, one of .Net objects, one of Python objects. It takes work to get from one to the other. I assume an Iron C# would utilize the .Net class structure. My advice: Stick with Iron Python and .Net classes. When Iron VB or Iron C# happens, it'll be a quick, maybe automatic, language translation. Besides, if enough of us use IronPython, Microsoft may change their mindset.
0
3,780
false
0
1
Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?
3,504,982
1
1
0
0
1
0
1.2
0
i'm new to python , and trying to write a script in order to send SMS's , after quick googling i found this lib: libgmail, and successfully installed it , this is the code i use to send SMS: !/usr/bin/env python import libgmail ga = libgmail.GmailAccount("[email protected]", "password") myCellEmail = "[email protected]" ga.login() msg=libgmail.GmailComposedMessage(myCellEmail, "", "Hello World! From python-libgmail!") ga.sendMessage(msg) i get the following error when trying to run it: Traceback (most recent call last): File "C:\Users\Amit\Desktop\SMS\sms.py", line 14, in ga.login() File "C:\Python27\lib\site-packages\libgmail.py", line 305, in login pageData = self._retrievePage(req) File "C:\Python27\lib\site-packages\libgmail.py", line 340, in _retrievePage req = ClientCookie.Request(urlOrRequest) File "build\bdist.win32\egg\mechanize_request.py", line 31, in init File "build\bdist.win32\egg\mechanize_rfc3986.py", line 62, in is_clean_uri TypeError: expected string or buffer if you have any ideas , please share .. thanks a lot amitos80
0
python,scripting,sms,libgmail
2010-08-15T12:59:00.000
0
3,487,447
As far as I know libgmail is not compatible with the current Gmail interface. If I am not mistaken libgmail is not actively maintained either. You might want to look at alternative options.
0
571
true
0
1
cant send SMS vla libgmail - python
3,487,491
2
3
0
0
4
1
0
0
I have a function that performs a hierarchical clustering on a list of input vectors. The return value is the root element of an object hierarchy, where each object represents a cluster. I want to test the following things: Does each cluster contain the correct elements (and maybe other properties as well)? Does each cluster point to the correct children? Does each cluster point to the correct parent? I have two problems here. First, how do I specify the expected output in a readable format. Second, how do I write a test-assertion accepts isomorphic variants of the expected data I provide? Suppose one cluster in the expected hierarchy has two children, A and B. Now suppose that cluster is represented by an object with the properties child1 and child2. I do not care whether child1 corresponds to cluster A or B, just that it corresponds to one of them, and that child2 corresponds to the other. The solution should be somewhat general because I will write several tests with different input data. Actually my main problem here is to find a way to specify the expected output in a readable and understandable way. Any suggestions?
0
python,unit-testing,readability
2010-08-15T13:16:00.000
0
3,487,507
It feels like there maybe some room for breaking your method into smaller pieces. Ones focused on dealing with parsing input and formatting output, could be separate from the actual clustering logic. This way tests around your clustering methods would be fewer and dealing with easily understood and testable data structures like dicts and lists.
0
72
false
0
1
Writing unittests for a function that returns a hierarchy of objects
3,488,720
2
3
0
2
4
1
1.2
0
I have a function that performs a hierarchical clustering on a list of input vectors. The return value is the root element of an object hierarchy, where each object represents a cluster. I want to test the following things: Does each cluster contain the correct elements (and maybe other properties as well)? Does each cluster point to the correct children? Does each cluster point to the correct parent? I have two problems here. First, how do I specify the expected output in a readable format. Second, how do I write a test-assertion accepts isomorphic variants of the expected data I provide? Suppose one cluster in the expected hierarchy has two children, A and B. Now suppose that cluster is represented by an object with the properties child1 and child2. I do not care whether child1 corresponds to cluster A or B, just that it corresponds to one of them, and that child2 corresponds to the other. The solution should be somewhat general because I will write several tests with different input data. Actually my main problem here is to find a way to specify the expected output in a readable and understandable way. Any suggestions?
0
python,unit-testing,readability
2010-08-15T13:16:00.000
0
3,487,507
If there are isomorphic results, you should probably have a predicate that can test for logical equivalence. This would likely be good for your code unit as well as helping to implement the unit test. This is the core of Manoj Govindan's answer without the string intermediates and since you aren't interested in string intermediates (presumably) then adding them to the test regime would be an unnecessary source of error. As to the readability issue, you'd need to show what you consider unreadable for a proper answer to be given. Perhaps the equivalence predicate will obviate this.
0
72
true
0
1
Writing unittests for a function that returns a hierarchy of objects
3,487,617
1
2
0
4
3
1
0.379949
0
With Ruby you can do gem install from the command line to install a module...even if it is not on your machine. Can you do that with python. Does someone know of a module? Seth
0
python,rubygems
2010-08-16T04:09:00.000
0
3,490,543
no it does not have a ruby installer that I know of. It does have easy_install and pip though. Your google-fu is lacking.
0
1,036
false
1
1
Does python have a ruby installer like gem that lets you install modules from the command line even if they are not on your machine?
3,490,551
1
2
0
0
3
0
0
0
I have about 200,000 text files that are placed in a bz2 file. The issue I have is that when I scan the bz2 file to extract the data I need, it goes extremely slow. It has to look through the entire bz2 file to fine the single file I am looking for. Is there anyway to speed this up? Also, I thought about possibly organizing the files in the tar.bz2 so I can instead have it know where to look. Is there anyway to organize files that are put into a bz2? More Info/Edit: I need to query the compressed file for each textfile. Is there a better compression method that supports such a large number of files and is as thoroughly compressed?
0
python,tar,bzip2,tarfile
2010-08-16T14:22:00.000
0
3,494,020
Bzip2 compresses in large blocks (900 KiB by default, I believe). One method that would speed up the scanning of the tar file dramatically, but would reduce compression performance, would be to compress each file individually and then tar the results together. This is essentially what Zip-format files are (though using zlib compression rather than bzip2). But you could then easily grab the tar index and only have to decompress the specific file(s) you are looking for. I don't think most tar programs offer much ability to organize files in any meaningful way, though you could write a program to do this for your special case (I know Python has tar-writing libraries though I've only used them once or twice). However, you'd still have the problem of having to decompress most of the data before you found what you were looking for.
0
965
false
0
1
Organizing files in tar bz2 file with python
3,494,091
2
5
0
4
6
0
0.158649
0
We have a decent set of unit tests on our code and those unit tests run in under 2 minutes. We also use TeamCity to do a build and to run tests after each check in. However, we still get issues where a developer "forgets" to run all the tests before a commit resulting in TeamCity failure which if this check in was done at 6PM may stay broken over night. "Forgets" is a generic term, there a couple other common reasons why even remembering to run the tests could result in TeamCity failure. Such as. -> A developer only checks in some of the modified files in his/her workspace. -> A file was modified outside of eclipse such that eclipse's team synchronize perspective does not detect it as dirty. How do you deal with this in your organization? We are thinking of introducing "check in procedure" for developers which will be an automated tool that will automatically run all unit tests and then commit all of the "dirty" files in your workspace. Have you had any experience with such process? Are you aware of any tools which may facilitate this process? Our dev environment is Python using Eclipse's PyDev plugin.
0
python,unit-testing,build-automation,teamcity
2010-08-16T15:22:00.000
1
3,494,585
I think it is more of a social problem rather than a deficiency of the automated systems. Yes, you can improve the systems in place, but they will be no match for someone thinking of the implications of their commit, and testing it before they hit commit.
0
2,165
false
0
1
Remembering to run tests before commit
3,494,671
2
5
0
7
6
0
1
0
We have a decent set of unit tests on our code and those unit tests run in under 2 minutes. We also use TeamCity to do a build and to run tests after each check in. However, we still get issues where a developer "forgets" to run all the tests before a commit resulting in TeamCity failure which if this check in was done at 6PM may stay broken over night. "Forgets" is a generic term, there a couple other common reasons why even remembering to run the tests could result in TeamCity failure. Such as. -> A developer only checks in some of the modified files in his/her workspace. -> A file was modified outside of eclipse such that eclipse's team synchronize perspective does not detect it as dirty. How do you deal with this in your organization? We are thinking of introducing "check in procedure" for developers which will be an automated tool that will automatically run all unit tests and then commit all of the "dirty" files in your workspace. Have you had any experience with such process? Are you aware of any tools which may facilitate this process? Our dev environment is Python using Eclipse's PyDev plugin.
0
python,unit-testing,build-automation,teamcity
2010-08-16T15:22:00.000
1
3,494,585
In one of the teams I was working before we had an agreement that anyone who breaks the tests buys bacon sandwiches for the whole team the next morning. Its extreme, but it works perfectly!
0
2,165
false
0
1
Remembering to run tests before commit
3,494,863
2
2
0
3
7
0
1.2
0
I am using Emacs 23.1.1 on GNU/Linux with autocomplete.el 1.3 and Ropemacs 0.6. In Lisp programming, autocomplete.el shows the documentation (known as 'QuickHelp' in autocomplete.el) of the suggested completions. Python completion with ropemacs works, but does not show quick help for the Python completion. Is it possible to enable it and did somebody make it work?
0
python,emacs
2010-08-17T19:20:00.000
0
3,506,105
Ropemacs does the job : Use the function rope-show-doc over the symbol or use the keybinding C-c d. Simple :)
0
607
true
0
1
Quickhelp for Python in Emacs autocomplete.el?
6,899,728
2
2
0
1
7
0
0.099668
0
I am using Emacs 23.1.1 on GNU/Linux with autocomplete.el 1.3 and Ropemacs 0.6. In Lisp programming, autocomplete.el shows the documentation (known as 'QuickHelp' in autocomplete.el) of the suggested completions. Python completion with ropemacs works, but does not show quick help for the Python completion. Is it possible to enable it and did somebody make it work?
0
python,emacs
2010-08-17T19:20:00.000
0
3,506,105
I stopped using all the autocomplete stuff in all my developing environments. They rarely do what I want. Either the lists is too long, or too short, or not sorted well. Therefore I use dabbrev-expand in all my modes global-set-key to tab. This works even quote well for text. Usually it is enough to get a good expansion from the local buffer where you are in. If I start typing in an empty buffer I open a second one which expand can use to look up its suggestions. This is not language sensitive, not does depend on the object you want to call a method of, but its still a big boost, and you get used to it. Maybe its not, you don't get "quick help" this way.
0
607
false
0
1
Quickhelp for Python in Emacs autocomplete.el?
6,889,131
3
10
0
6
3
0
1
0
I may be posting a premature question, and maybe I'm just freaking out for no reason, but the way Oracle is handling Java is not very promising. I am a nerd who fell in love with Java from the first sight, and use it all the time in my personal/freelance projects but now I am thinking of a replacement. I am fluent in C#/VB.NET too but I am looking for something more like: Open Source Compiled Cross-Platform Object Oriented Large standard library Extensive documentation Web development is a major plus I was thinking about a compromise: Python/Django for web development (or PHP), and Qt for thick client development. Anyone with better thoughts?
0
java,python,qt,programming-languages,replace
2010-08-17T19:35:00.000
0
3,506,252
Might be worth loking at the other JVM languages - Clojure and Scala are the two I personally think are most promising. Yes you are on the JVM, but you're pretty independent from Java the langauage and don't have to use any Sun/Oracle implementations if you don't want to. Having said that - I think that you are worrying a little too much about Java, too many players (including Oracle!) have too much invested to let it go too far off course.
0
3,718
false
1
1
What languages would be a good replacement for Java?
3,506,325
3
10
0
0
3
0
0
0
I may be posting a premature question, and maybe I'm just freaking out for no reason, but the way Oracle is handling Java is not very promising. I am a nerd who fell in love with Java from the first sight, and use it all the time in my personal/freelance projects but now I am thinking of a replacement. I am fluent in C#/VB.NET too but I am looking for something more like: Open Source Compiled Cross-Platform Object Oriented Large standard library Extensive documentation Web development is a major plus I was thinking about a compromise: Python/Django for web development (or PHP), and Qt for thick client development. Anyone with better thoughts?
0
java,python,qt,programming-languages,replace
2010-08-17T19:35:00.000
0
3,506,252
C# is the only thing that will meet your needs and not feel hopelessly archaic, or frustrate with limited library. For open source/non-windows, use mono. It's a good, mature implementation of most of what's important in the CLR. Some things (WPF, WCF, etc) are "missing" from mono, but these aren't so much part of the platform as they are windows-specific proprietary toolkits. Some of them are being implemented slowly in mono, some aren't. Coming from java you won't miss them because you're looking for a platform and good standard libraries to build upon, not a gui toolkit or whiz-bang communication framework. As far as a platform to build stuff with that's "like" java and offers similar levels of functionality, C# + CLR is the clearest option.
0
3,718
false
1
1
What languages would be a good replacement for Java?
3,509,044
3
10
0
1
3
0
0.019997
0
I may be posting a premature question, and maybe I'm just freaking out for no reason, but the way Oracle is handling Java is not very promising. I am a nerd who fell in love with Java from the first sight, and use it all the time in my personal/freelance projects but now I am thinking of a replacement. I am fluent in C#/VB.NET too but I am looking for something more like: Open Source Compiled Cross-Platform Object Oriented Large standard library Extensive documentation Web development is a major plus I was thinking about a compromise: Python/Django for web development (or PHP), and Qt for thick client development. Anyone with better thoughts?
0
java,python,qt,programming-languages,replace
2010-08-17T19:35:00.000
0
3,506,252
I too would like another Java-like technology to come along. Lately I've been doing Flex/Actionscript. While I really enjoy it, Actionscript technology seriously lacks the elegance that Java has. Adobe can write some good cross platform APIs, but they just don't have the head capital to build elegant languages and compilers. I've also tried Ruby, but the VM for Ruby is really bad. I've gone back to Java after my flirtation with other technologies and I think it's because the language is good enough, but the JVM is by far the best out there. So do you want to stay with the JVM or do you really want to the leave the JVM altogether? Staying on the JVM there are lots of options: JRuby, Scala, Groovy, Javascript, Clojure are the big players. However, there are tons of great languages that can take advantage of the JVM's features. Leaving the JVM there are still good options like python, ruby, and erlang. But you give up some of the nice features of the JVM like performance (big one), and the ability to drop down to a nice language like Java if you need speed. Those others mean using C or nothing at all. I finally stopped worrying about Java's future. Sun did all it could to screw it up and it still turned out pretty darn good. I think Opensource has a lot more influence over Java's success than Oracle or Sun could ever have had.
0
3,718
false
1
1
What languages would be a good replacement for Java?
3,506,402
1
3
0
3
1
0
0.197375
0
I need to send integers greater than 255? Does anyone know how to do this?
0
python,arduino
2010-08-17T23:20:00.000
0
3,507,732
Encode them into binary strings with Python's struct module. I don't know if arduino wants them little-endian or big-endian, but, if its docs aren't clear about this, a little experiment should easily settle the question;-).
0
14,924
false
0
1
Sending integer values to Arduino from PySerial
3,507,854
2
3
0
0
1
0
0
0
How can I know if the user is connected to the local machine via ssh in my python script?
0
python,ssh
2010-08-18T00:13:00.000
1
3,507,980
Am I correct in assuming you're running your script on some sort of UNIX/Linux system? If so, you can just type "users" on the command-line, and it will show you the currently logged in users. Also, if you call the "lastlog" command, that will show you all the users on the system and the last time they all logged in to the machine.
0
416
false
0
1
How can I know if the user is connected to the local machine via ssh in my python script?
3,508,010
2
3
0
0
1
0
0
0
How can I know if the user is connected to the local machine via ssh in my python script?
0
python,ssh
2010-08-18T00:13:00.000
1
3,507,980
Check any of the SSH variables SSH_CONNECTION, SSH_CLIENT, or SSH_TTY. However, these can be unset by the user. Check the output of who am i. It will end with the remote system identification in brackets if you are connected remotely. Make sure to handle x-term sessions which will have a colon (:) in the remote system id.
0
416
false
0
1
How can I know if the user is connected to the local machine via ssh in my python script?
3,508,136
1
1
0
6
1
1
1.2
0
I'm not sure if it's because sys.stderr.write is faster.
0
python,logging
2010-08-18T09:41:00.000
0
3,510,747
imaplib is much older (it was in Python1.5.2) than the logging module (Python2.3), so perhaps noone has needed to update it to use logging yet
0
72
true
0
1
Why does python libs (eg imaplib) does not use logging but use sys.stderr.write?
3,510,824
2
5
0
2
4
1
0.07983
0
Are there any languages which feature static type checking like in C++ with modern syntax like in Python, and does not have GIL? I belive, Python 3 with ability to explicitly declare type of each variable would be 'almost there', but GIL makes me sad. Java is nice, but I need something more 'embedable' without bulky JRE. Update: Anything .NET-related or non-open source is a no-go. Update2: I need explicit+strong typing to write safer code in the expense of development speed. GIL is important as the code is going to be quite computing extensive and will run on multicore servers, so it has to effectively use multiple CPU. Update3: Target platform is Linux(Debian) on x86
0
java,python,gil
2010-08-18T12:15:00.000
0
3,511,922
After reading your updated spec: I need explicit+strong typing to write safer code in the expense of development speed. GIL is important as the code is going to be quite computing extensive and will run on multicore servers, so it has to effectively use multiple CPU What exactly does "computing extensive" mean? What problem domain? What do others who work in this problem domain use? If you are serious with this specification, you can't do much other things than using C++ in connection with well-tested libraries for multithreading and numerical computing. my $0.02 rbo
0
887
false
0
1
Looking for strong/explicit-typed language without GIL
3,512,342
2
5
0
4
4
1
0.158649
0
Are there any languages which feature static type checking like in C++ with modern syntax like in Python, and does not have GIL? I belive, Python 3 with ability to explicitly declare type of each variable would be 'almost there', but GIL makes me sad. Java is nice, but I need something more 'embedable' without bulky JRE. Update: Anything .NET-related or non-open source is a no-go. Update2: I need explicit+strong typing to write safer code in the expense of development speed. GIL is important as the code is going to be quite computing extensive and will run on multicore servers, so it has to effectively use multiple CPU. Update3: Target platform is Linux(Debian) on x86
0
java,python,gil
2010-08-18T12:15:00.000
0
3,511,922
Anything in the ML family might work for you. Ocaml is a great place to start, but it does have a stop-the-world GC last I looked. Haskell is famous as a lab for innovative concurrency models. Python's comprehensions came from Haskell, where they'rr a convenient syntax for some very fundamental ideas. And Erlang is strongly dynamcally typed, fun to write in, and does concurrency better than anybody else.
0
887
false
0
1
Looking for strong/explicit-typed language without GIL
3,512,157
1
5
0
-2
12
1
-0.07983
0
I want to run a cpu intensive program in Python across multiple cores and am trying to figure out how to write C extensions to do this. Are there any code samples or tutorials on this?
0
python,python-c-extension
2010-08-18T16:46:00.000
0
3,514,495
multiprocessing is easy. if thats not fast enough, your question is complicated.
0
6,155
false
0
1
How to use C extensions in python to get around GIL
3,514,728
3
5
0
1
1
0
0.039979
0
So I have a C program to interface with an i2c device. I need to interface to that device from python. I'm just wondering if it's worth porting the program into a python module or if the amount of effort involved in porting won't outweigh just executing the program using subprocess. I know I'm sure it's different for every application, but I'd like to know if it's even worth my time to learn the python C extensions and port this program. Update: I have full access to the source of both the C as well as the python. But there is already substantial work done on the python side and I'd like to keep changes to that as minimal is possible, if that matters. And I'd also like to minimize the changes that have to be made to the C. It's doable, but I didn't write it and it involves a lot of by addressing that I'd rather not have to redo.
0
python,c,python-module,i2c
2010-08-18T21:49:00.000
1
3,517,011
Don't use the Python C API, there are much easier alternatives, most notably cython. cython is a Python-like language, which compiles into C code for the Python c library. Basically it's C with Python syntax and features (e.g. nice for loops, exceptions, etc.). cython is clearly the most recommendable way to write C extensions for python. You might also want to take a look at ctypes, a module to dynamically load C libraries and call functions from them. If your i2c-code is available as shared library, you can get away with no native binding at all, which eases development and distribution.
0
471
false
0
1
Extending python with C module
3,517,141
3
5
0
0
1
0
0
0
So I have a C program to interface with an i2c device. I need to interface to that device from python. I'm just wondering if it's worth porting the program into a python module or if the amount of effort involved in porting won't outweigh just executing the program using subprocess. I know I'm sure it's different for every application, but I'd like to know if it's even worth my time to learn the python C extensions and port this program. Update: I have full access to the source of both the C as well as the python. But there is already substantial work done on the python side and I'd like to keep changes to that as minimal is possible, if that matters. And I'd also like to minimize the changes that have to be made to the C. It's doable, but I didn't write it and it involves a lot of by addressing that I'd rather not have to redo.
0
python,c,python-module,i2c
2010-08-18T21:49:00.000
1
3,517,011
I've had good luck using ctypes. Whatever you choose, though, you may not gain any time this time but the next time around your effort will be much faster than doing the whole thing in C.
0
471
false
0
1
Extending python with C module
3,517,152
3
5
0
2
1
0
0.07983
0
So I have a C program to interface with an i2c device. I need to interface to that device from python. I'm just wondering if it's worth porting the program into a python module or if the amount of effort involved in porting won't outweigh just executing the program using subprocess. I know I'm sure it's different for every application, but I'd like to know if it's even worth my time to learn the python C extensions and port this program. Update: I have full access to the source of both the C as well as the python. But there is already substantial work done on the python side and I'd like to keep changes to that as minimal is possible, if that matters. And I'd also like to minimize the changes that have to be made to the C. It's doable, but I didn't write it and it involves a lot of by addressing that I'd rather not have to redo.
0
python,c,python-module,i2c
2010-08-18T21:49:00.000
1
3,517,011
One of the first Python programs I wrote was a script that called functions from a C library, which sounds close to what you're doing. I used ctypes, and I was impressed as to how easy it was: I could access each library function from python by writing just a few lines of python (no C at all!). I'd tried the Python C API before, and it required a lot more boilerplate. I havent tried SWIG or Cython.
0
471
false
0
1
Extending python with C module
3,517,190
1
3
0
-2
3
1
-0.132549
0
I'd like to be able to enter an interactive session, preferably with IPython, if a unit test fails. Is there an easy way to do this? edit: by "interactive session" I mean a full Python REPL rather than a pdb shell. edit edit: As a further explanation: I'd like to be able to start an interactive session that has access to the context in which the test failure occurred. So for example, the test's self variable would be available.
0
python,unit-testing,interactive,ipython
2010-08-18T22:58:00.000
0
3,517,410
Are you really sure you want to do this? Your unit tests should do one thing, should be well-named, and should clearly print what failed. If you do all of that, the failure message will pinpoint what went wrong; no need to go look at it interactively. In fact, one of the big advantages of TDD is that it helps you avoid having to go into the debugger at all to diagnose problems.
0
1,014
false
0
1
drop into an interactive session to examine a failed unit test
3,517,604
2
2
0
3
0
0
1.2
1
I've develop webmail client for any mail server. I want to implement message conversion for it — for example same emails fwd/reply/reply2all should be shown together like gmail does... My question is: what's the key to find those emails which are either reply/fwd or related to the original mail....
0
python,imap,pop3,imaplib,poplib
2010-08-20T12:34:00.000
0
3,530,851
The In-Reply-To header of the child should have the value of the Message-Id header of the parent(s).
0
1,161
true
0
1
How to maintain mail conversion (reply / forward / reply to all like gmail) of email using Python pop/imap lib?
3,566,252
2
2
0
2
0
0
0.197375
1
I've develop webmail client for any mail server. I want to implement message conversion for it — for example same emails fwd/reply/reply2all should be shown together like gmail does... My question is: what's the key to find those emails which are either reply/fwd or related to the original mail....
0
python,imap,pop3,imaplib,poplib
2010-08-20T12:34:00.000
0
3,530,851
Google just seems to chain messages based on the subject line (so does Apple Mail by the way.)
0
1,161
false
0
1
How to maintain mail conversion (reply / forward / reply to all like gmail) of email using Python pop/imap lib?
3,530,868
11
14
0
7
13
1
1
0
Working on different projects I have the choice of selecting different programming languages, as long as the task is done. I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C. The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing. Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example? And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).
0
python,c,performance
2010-08-20T18:27:00.000
1
3,533,759
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example? Yes. The noticeable differences are these There's much less Python code. The Python code is much easier to read. Python supports really nice unit testing, so the Python code tends to be higher quality. You can write the Python code more quickly, since there are fewer quirky language features. No preprocessor, for example, really saves a lot of hacking around. Super-experience C programmers hardly notice it. But all that #include sandwich stuff and making the .h files correct is remarkably time-consuming. Python can be easier to package and deploy, since you don't need a big fancy make script to do a build.
0
14,463
false
0
1
Performance differences between Python and C
3,533,838
11
14
0
0
13
1
0
0
Working on different projects I have the choice of selecting different programming languages, as long as the task is done. I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C. The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing. Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example? And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).
0
python,c,performance
2010-08-20T18:27:00.000
1
3,533,759
C is definitely faster than Python because Python is written in C. C is middle level language and hence faster but there not much a great difference between C & Python regarding executable time it takes. but it is really very easy to write code in Python than C and it take much shorter time to write code and learn Python than C. Because its easy to write its easy to test also.
0
14,463
false
0
1
Performance differences between Python and C
15,903,255
11
14
0
-1
13
1
-0.014285
0
Working on different projects I have the choice of selecting different programming languages, as long as the task is done. I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C. The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing. Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example? And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).
0
python,c,performance
2010-08-20T18:27:00.000
1
3,533,759
The excess time to write the code in C compared to Python will be exponentially greater than the difference between C and Python execution speed.
0
14,463
false
0
1
Performance differences between Python and C
3,539,538
11
14
0
-1
13
1
-0.014285
0
Working on different projects I have the choice of selecting different programming languages, as long as the task is done. I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C. The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing. Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example? And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).
0
python,c,performance
2010-08-20T18:27:00.000
1
3,533,759
You will find C is much slower. Your developers will have to keep track of memory allocation, and use libraries (such as glib) to handle simple things such as dictionaries, or lists, which python has built-in. Moreover, when an error occurs, your C program will typically just crash, which means you'll need to get the error to happen in a debugger. Python would give you a stack trace (typically). Your code will be bigger, which means it will contain more bugs. So not only will it take longer to write, it will take longer to debug, and will ship with more bugs. This means that customers will notice the bugs more often. So your developers will spend longer fixing old bugs and thus new features will get done more slowly. In the mean-time, your competitors will be using a sensible programming language and their products will be increasing in features and usability, rapidly yours will look bad. Your customers will leave and you'll go out of business.
0
14,463
false
0
1
Performance differences between Python and C
3,536,830
11
14
0
0
13
1
0
0
Working on different projects I have the choice of selecting different programming languages, as long as the task is done. I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C. The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing. Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example? And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).
0
python,c,performance
2010-08-20T18:27:00.000
1
3,533,759
Across all programs, it isn't really possible to say whether things will be quicker or slower on average in Python or C. For the programs that I've implemented in both languages, using similar algorithms, I've seen no improvement (and sometimes a performance degradation) for string- and IO-heavy code, when reimplementing python code in C. The execution time is dominated by allocation and manipulation of strings (which functionality python implements very efficiently) and waiting for IO operations (which incurs the same overhead in either language), so the extra overhead of python makes very little difference. But for programs that do even simple operations on image files, say (images being large enough for processing time to be noticeable compared to IO), C is enormously quicker. For this sort of task the bulk of the time running the python code is spent doing Python Stuff, and this dwarfs the time spent on the underlying operations (multiply, add, compare, etc.). When reimplemented as C, the bureaucracy goes away, the computer spends its time doing real honest work, and for that reason the thing runs much quicker. It's not uncommon for the python code to run in (say) 5 seconds where the C code runs in (say) 0.05. So that's a 100x increase -- but in absolute terms, this is not so big a deal. It takes so much less longer to write python code than it does to write C code that your program would have to be run some huge number of times to turn a time profit. I often reimplement in C, for various reasons, but if you don't have this requirement then it's probably not worth bothering. You won't get that part of your life back, and next year computers will be quicker.
0
14,463
false
0
1
Performance differences between Python and C
3,534,845
11
14
0
1
13
1
0.014285
0
Working on different projects I have the choice of selecting different programming languages, as long as the task is done. I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C. The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing. Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example? And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).
0
python,c,performance
2010-08-20T18:27:00.000
1
3,533,759
It really depends a lot on what your doing and if the algorithm in question is available in Python via a natively compiled library. If it is, then I believe you'll be looking at performance numbers close enough that Python is most likely your answer -- assuming it's your preferred language. If you must implement the algorithm yourself, depending on the amount of logic required and the size of your data set, C/C++ may be the better option. It's hard to provide a less nebulous answer without more information.
0
14,463
false
0
1
Performance differences between Python and C
3,534,210
11
14
0
4
13
1
0.057081
0
Working on different projects I have the choice of selecting different programming languages, as long as the task is done. I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C. The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing. Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example? And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).
0
python,c,performance
2010-08-20T18:27:00.000
1
3,533,759
If your text files that you are sorting and parsing are large, use C. If they aren't, it doesn't matter. You can write poor code in any language though. I have seen simple code in C for calculating areas of triangles run 10x slower than other C code, because of poor memory management, use of structures, pointers, etc. Your I/O algorithm should be independent of your compute algorithm. If this is the case, then using C for the compute algorithm can be much faster.
0
14,463
false
0
1
Performance differences between Python and C
3,534,052
11
14
0
4
13
1
0.057081
0
Working on different projects I have the choice of selecting different programming languages, as long as the task is done. I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C. The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing. Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example? And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).
0
python,c,performance
2010-08-20T18:27:00.000
1
3,533,759
The first rule of computer performance questions: Your mileage will vary. If small performance differences are important to you, the only way you will get valid information is to test with your configuration, your data, and your benchmark. "Small" here is, say, a factor of two or so. The second rule of computer performance questions: For most applications, performance doesn't matter -- the easiest way to write the app gives adequate performance, even when the problem scales. If that is the case (and it is usually the case) don't worry about performance. That said: C compiles down to machine executable and thus has the potential to execute as at least as fast as any other language Python is generally interpreted and thus may take more CPU than a compiled language Very few applications are "CPU bound." I/O (to disk, display, or memory) is not greatly affected by compiled vs interpreted considerations and frequently is a major part of computer time spent on an application Python works at a higher level of abstraction than C, so your development and debugging time may be shorter My advice: Develop in the language you find the easiest with which to work. Get your program working, then check for adequate performance. If, as usual, performance is adequate, you're done. If not, profile your specific app to find out what is taking longer than expected or tolerable. See if and how you can fix that part of the app, and repeat as necessary. Yes, sometimes you might need to abandon work and start over to get the performance you need. But having a working (albeit slow) version of the app will be a big help in making progress. When you do reach and conquer that performance goal you'll be answering performance questions in SO rather than asking them.
0
14,463
false
0
1
Performance differences between Python and C
3,533,974
11
14
0
10
13
1
1
0
Working on different projects I have the choice of selecting different programming languages, as long as the task is done. I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C. The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing. Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example? And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).
0
python,c,performance
2010-08-20T18:27:00.000
1
3,533,759
In general IO bound work will depend more on the algorithm then the language. In this case I would go with Python because it will have first class strings and lots of easy to use libraries for manipulating files, etc.
0
14,463
false
0
1
Performance differences between Python and C
3,533,800
11
14
0
11
13
1
1
0
Working on different projects I have the choice of selecting different programming languages, as long as the task is done. I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C. The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing. Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example? And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).
0
python,c,performance
2010-08-20T18:27:00.000
1
3,533,759
C will absolutely crush Python in almost any performance category, but C is far more difficult to write and maintain and high performance isn't always worth the trade off of increased time and difficulty in development. You say you're doing things like text file processing, but what you omit is how much text file processing you're doing. If you're processing 10 million files an hour, you might benefit from writing it in C. But if you're processing 100 files an hour, why not use python? Do you really need to be able to process a text file in 10ms vs 50ms? If you're planning for the future, ask yourself, "Is this something I can just throw more hardware at later?" Writing solid code in C is hard. Be sure you can justify that investment in effort.
0
14,463
false
0
1
Performance differences between Python and C
3,534,125
11
14
0
37
13
1
1.2
0
Working on different projects I have the choice of selecting different programming languages, as long as the task is done. I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C. The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing. Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example? And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).
0
python,c,performance
2010-08-20T18:27:00.000
1
3,533,759
Use python until you have a performance problem. If you ever have one figure out what the problem is (often it isn't what you would have guessed up front). Then solve that specific performance problem which will likely be an algorithm or data structure change. In the rare case that your problem really needs C then you can write just that portion in C and use it from your python code.
0
14,463
true
0
1
Performance differences between Python and C
3,533,877
1
2
0
2
0
0
1.2
1
Does python have a full fledged email library with things for pop, smtp, pop3 with ssl, mime? I want to create a web mail interface that pulls emails from email servers, and then shows the emails, along with attachments, can display the sender, subject, etc. (handles all the encoding issues etc). It's one thing to be available in the libraries and another for them to be production ready. I'm hoping someone who has used them to pull emails w/attachments etc. in a production environment can comment on this.
0
python,email,smtp,mime,pop3
2010-08-21T18:16:00.000
0
3,538,430
It has all the components you need, in a more modular and flexible arrangement than you appear to envisage -- the standard library's email package deals with the message once you have received it, and separate modules each deal with means of sending and receiving, such as pop, smtp, imap. SSL is an option for each of them (if the counterpart, e.g. mail server, supports it, of course), being basically just "a different kind of socket". Have you looked at the rich online docs for all of these standard library modules?
0
513
true
0
1
Does python have a robust pop3, smtp, mime library where I could build a webmail interface?
3,538,453
1
2
0
2
2
1
1.2
0
I'm working from inside an ipython shell and often need to reload the script files that contain my functions-under-construction. Inside my main.py I have: def myreload(): execfile("main.py") execfile("otherfile.py") Calling myreload() works fine if I have already ran in the same ipython session the execfile commands directly. However, for some reason, if the session is fresh and I just called execfile("main.py"), then myreload() doesn't actually make the functions from inside otherfile.py available. It doesn't throw any error though. Any ideas?
0
python,ipython,execfile
2010-08-22T05:54:00.000
1
3,540,368
Functions create a new scope. execfile() runs the script in the current scope. What you are doing will not work.
0
2,290
true
0
1
Python shell and execfile scope
3,540,375
2
5
0
6
1
1
1
0
I'm a school teacher who spent the summer writing a vocab training program in python that uses text available from wikipedia and gutenberg. Now all I have to do is figure out a way to filter out curse words so that I can distribute to students. Normally I would just have an array (list) of those curse words and do a simple filter. The problem though is that the py file itself it openable by these students, seeing those words. If I put it in a separate file, somehow encrypted, then they could just delete that file and the output wouldn't be filtered. Any ideas for workarounds?
0
python,filter
2010-08-22T15:46:00.000
0
3,542,095
If all the students are running the same version of Python (e.g. at a computer lab), you can distribute pyc files. This is just obfuscation, but it will deter casual users.
0
674
false
0
1
How to "hide" curse words in a py file?
3,542,173
2
5
0
1
1
1
0.039979
0
I'm a school teacher who spent the summer writing a vocab training program in python that uses text available from wikipedia and gutenberg. Now all I have to do is figure out a way to filter out curse words so that I can distribute to students. Normally I would just have an array (list) of those curse words and do a simple filter. The problem though is that the py file itself it openable by these students, seeing those words. If I put it in a separate file, somehow encrypted, then they could just delete that file and the output wouldn't be filtered. Any ideas for workarounds?
0
python,filter
2010-08-22T15:46:00.000
0
3,542,095
Why not distribute the compiled python .*pyc files instead? They could still lookup the strings if they wanted, but it will likely deter casual browsing of the file, which may be sufficient for your needs.
0
674
false
0
1
How to "hide" curse words in a py file?
3,542,374
1
3
0
2
0
0
0.132549
0
Does anyone know where I could find reviews or reports on tasks that people implemented in two or more scripting languages to see which was more suited to a specific job? I want to know which languages are best suited to which types of operation so that I can make the most of them. "Types of operation" could be sockets, the file system, logic evaluation, regex, or drawing. I'm mostly interested in Python, PHP, Perl, and Ruby.
0
php,python,ruby,perl,benchmarking
2010-08-22T20:19:00.000
0
3,543,193
The best thing to do would be to create your own benchmarks for the specific tasks you are interested in. Pick languages that you like working in and then write benchmarks for the system you will be using and the task you will be performing. If you are very concerned about speed I would also recommend looking at the individual operations and how to optimize them in each of the languages (examples: argument order, memory usage...)
0
1,097
false
0
1
Benchmarks of scripting languages doing the same task?
3,543,230
1
3
0
3
15
0
0.197375
0
How do i set a timeout value for python's mechanize?
0
python,timeout,mechanize
2010-08-24T01:22:00.000
0
3,552,928
If you're using Python 2.6 or better, and a correspondingly updated version of mechanize, mechanize.urlopen should accept a timeout=... optional argument which seems to be what you're looking for.
0
9,833
false
0
1
how do i set a timeout value for python's mechanize?
3,553,063
1
4
0
0
3
0
0
0
I have some bash scripts, some simple ones to copy, search, write lines to files and so on. I am an Ubuntu. and I've searched in google, but it seems that everybody is doing that on python. I could do these on python, but since I am not a python programmer, I just know the basics. I have no idea of how calling a sh script from a GUI written on python. If someone has a link or something to say, please drop a line. regards, Mario
0
python,user-interface,bash
2010-08-24T11:41:00.000
1
3,556,027
basically, all bash does is start other programs (and do symbolic math on the command line). So no, you're going to have to involve some other program.
0
2,093
false
0
1
Is there a way of having a GUI for bash scripts?
3,556,046
1
1
0
1
8
1
0.197375
0
I'm just starting to work on a tornado application that is having some CPU issues. The CPU time will monotonically grow as time goes by, maxing out the CPU at 100%. The system is currently designed to not block the main thread. If it needs to do something that blocks and asynchronous drivers aren't available, it will spawn another thread to do the blocking operation. Thus we have the main thread being almost totally CPU-bound and a bunch of other threads that are almost totally IO-bound. From what I've read, this seems to be the perfect way to run into problems with the GIL. Plus, my profiling shows that we're spending a lot of time waiting on signals (which I'm assuming is what __semwait_signal is doing), which is consistent with the effects the GIL would have in my limited understanding. If I use sys.setcheckinterval to set the check interval to 300, the CPU growth slows down significantly. What I'm trying to determine is whether I should increase the check interval, leave it at 300, or be scared with upping it. After all, I notice that CPU performance gets better, but I'm a bit concerned that this will negatively impact the system's responsiveness. Of course, the correct answer is probably that we need to rethink our architecture to take the GIL into account. But that isn't something that can be done immediately. So how do I determine the appropriate course of action to take in the short-term?
0
python,multithreading,tornado,gil
2010-08-24T17:55:00.000
0
3,559,457
The first thing I would check for would be to ensure that you're properly exiting threads. It's very hard to figure out what's going on with just your description to go from, but you use the word "monotonically," which implies that CPU use is tied to time rather than to load. You may very well be running into threading limits of Python, but it should vary up and down with load (number of active threads,) and CPU usage (context switching costs) should reduce as those threads exit. Is there some reason for a thread, once created, to live forever? If that's the case, prioritize that rearchitecture. Otherwise, short term would be to figure out why CPU usage is tied to time and not load. It implies that each new thread has a permanent, irreversible cost in your system - meaning it never exits.
0
765
false
0
1
How do I determine the appropriate check interval?
3,562,109
1
2
0
1
0
1
0.099668
0
I want to be able to use the PIL library on a web hosting machine. The machine has Python 2.4.3 installed, but not the PIL library. I tried downloading the PIL source and putting the PIL folder into my directory. It kind of works, except when I need to do some actual image processing, which brings up an ImportError, saying that "The _imaging C module is not installed". Googling this, it seems like I would need to throw an _imaging.so file into the PIL folder, but I couldn't find a precompiled one online. At this point, I'm not sure if I'm even on the right track. What should I do from here? Any help is appreciated. Thanks.
0
python,web-hosting,python-imaging-library
2010-08-24T19:25:00.000
0
3,560,246
You need to compile that module. Running the setup.py install command should do it for you, provided the host has a working compiler and the required libraries. You can use virtualenv to have it installed somewhere where you have rights to put files (by default it would try to install it system-wide). If it doesn't have a working compiler and right libraries and header files, then you need to either compile it on another computer with the same architecture and copy it, or find the packages for whatever operating system your host is running and extract the right files from them. By the way, just asking them to install PIL could work too!
0
192
false
0
1
Using PIL on web hosting machine
3,560,296
1
2
0
3
5
0
1.2
0
We are using Hudson and coverage.py to report the code coverage of our test suite. Hudson breaks down coverage into: packages files classes lines conditionals Coverage.py only reports coverage on files executed/imported during the tests, and so it seems is oblivious to any files not executed during the tests. Is there ever an instance where files would not report 100% coverage?
0
python,hudson,code-coverage,coverage.py,python-coverage
2010-08-25T03:19:00.000
0
3,562,643
Currently, coverage.py doesn't know how to find files that are never executed and report them as not covered, but that will be coming in the next release. So now, the file coverage will always be 100%. This is an area where Hudson (using the Cobertura plugin) and coverage.py don't mesh very well.
0
517
true
0
1
When would my Python test suite file coverage not be 100%?
3,562,678
1
4
0
3
0
0
0.148885
0
i have prepared a project in python language ie a TEXT TO SPEECH synthesizer. Which took a total on 1500 lines of code. But there few parts of code due to which it is taking so much time to run the code, i want to replace that parts of code in C/c++ lang so that it runs faster. So i want to know how can i run these parts of code in C++ or improve its speed in any other way?? please suggest,
0
python
2010-08-25T16:54:00.000
0
3,568,371
You have a few options: As Radomir mentioned, Cython might be a good choice: it's essentially a restricted Python with type declarations, automatically translated into C then compiled for execution. If you want to use pure C, you can write a Python extension module using the Python C API. This is a good way to go if you need to manipulate Python data structures in your C code. Using the Python C API, you write in C, but with full access to the Python types and methods. Or, you can write a pure C dll, then invoke it with ctypes. This is a good choice if you don't need any access to Python data structures in your C code. With this technique, your C code only deals with C types, and your Python code has to understand how to use ctypes to get at that C data.
0
106
false
0
1
how to replicate parts of code in python into C to execution faster?
3,568,664
2
3
0
3
9
1
0.197375
0
So I have a class in a module that has some static methods. A couple of these static methods just do crc checks and stuff, and they're not really useful outside of the class (I would just make them private static methods in java or C++). I'm wondering if I should instead make them global class functions (outside of the class). Is there any benefit for doing it either way? The class is being imported by from module import class so I'm not worried about having those modules pulled in as well. But should I just make them class methods so that from module import * is safer or something?
0
python,global,static-methods
2010-08-25T22:48:00.000
0
3,570,823
Make them module-level functions, and prefix them with a single underscore so that consumers understand that they are for private use.
0
2,735
false
0
1
Static method vs module function in python
3,570,851
2
3
0
3
9
1
0.197375
0
So I have a class in a module that has some static methods. A couple of these static methods just do crc checks and stuff, and they're not really useful outside of the class (I would just make them private static methods in java or C++). I'm wondering if I should instead make them global class functions (outside of the class). Is there any benefit for doing it either way? The class is being imported by from module import class so I'm not worried about having those modules pulled in as well. But should I just make them class methods so that from module import * is safer or something?
0
python,global,static-methods
2010-08-25T22:48:00.000
0
3,570,823
If they are not useful outside of the class, what is the motivation to make them module methods? Keeping them as static method makes the name space cleaner. The only advantage to move it outside maybe so that people can reference them without using qualified them the class name. Say you have a log method that got reference in a ton of places, this may make sense as a stylistic choice.
0
2,735
false
0
1
Static method vs module function in python
3,571,114
1
1
0
0
0
0
1.2
0
I have been developing under Python/Snowleopard happily for the part 6 months. I just upgraded Python to 2.6.5 and a whole bunch of libraries, including psycopg2 and Turbogears. I can start up tg-admin and run some queries with no problems. Similarly, I can run my web site from the command line with no problems. However, if I try to start my application under Aptana Studio, I get the following exception while trying to import psychopg2: ('dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/psycopg2/_psycopg.so, 2): Symbol not found: _PQbackendPID\n Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/psycopg2/_psycopg.so\n Expected in: flat namespace\n in /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/psycopg2/_psycopg.so',) This occurs after running the following code: try: import psycopg2 as psycopg except ImportError as ex: print "import failed :-( xxxxxxxx = " print ex.args I have confirmed that the same version of python is being run as follows: import sys print "python version: ", sys.version_info Does anyone have any ideas? I've seem some references alluding to this being a 64-bit issue. - dave
1
python,turbogears,psycopg
2010-08-26T01:41:00.000
0
3,571,495
Problem solved (to a point). I was running 64 bit python from Aptana Studio and 32 bit python on the command line. By forcing Aptana to use 32 bit python, the libraries work again and all is happy.
0
296
true
0
1
Psycopg2 under osx works on commandline but fails in Aptana studio
3,571,749
3
5
0
0
13
0
0
1
They didn't mention this in python documentation. And recently I'm testing a website simply refreshing the site using urllib2.urlopen() to extract certain content, I notice sometimes when I update the site urllib2.urlopen() seems not get the newly added content. So I wonder it does cache stuff somewhere, right?
0
python,urllib2,urlopen
2010-08-27T16:34:00.000
0
3,586,295
If you make changes and test the behaviour from browser and from urllib, it is easy to make a stupid mistake. In browser you are logged in, but in urllib.urlopen your app can redirect you always to the same login page, so if you just see the page size or the top of your common layout, you could think that your changes have no effect.
0
12,290
false
0
1
Does urllib2.urlopen() cache stuff?
38,239,971
3
5
0
10
13
0
1.2
1
They didn't mention this in python documentation. And recently I'm testing a website simply refreshing the site using urllib2.urlopen() to extract certain content, I notice sometimes when I update the site urllib2.urlopen() seems not get the newly added content. So I wonder it does cache stuff somewhere, right?
0
python,urllib2,urlopen
2010-08-27T16:34:00.000
0
3,586,295
So I wonder it does cache stuff somewhere, right? It doesn't. If you don't see new data, this could have many reasons. Most bigger web services use server-side caching for performance reasons, for example using caching proxies like Varnish and Squid or application-level caching. If the problem is caused by server-side caching, usally there's no way to force the server to give you the latest data. For caching proxies like squid, things are different. Usually, squid adds some additional headers to the HTTP response (response().info().headers). If you see a header field called X-Cache or X-Cache-Lookup, this means that you aren't connected to the remote server directly, but through a transparent proxy. If you have something like: X-Cache: HIT from proxy.domain.tld, this means that the response you got is cached. The opposite is X-Cache MISS from proxy.domain.tld, which means that the response is fresh.
0
12,290
true
0
1
Does urllib2.urlopen() cache stuff?
3,586,796
3
5
0
-2
13
0
-0.07983
1
They didn't mention this in python documentation. And recently I'm testing a website simply refreshing the site using urllib2.urlopen() to extract certain content, I notice sometimes when I update the site urllib2.urlopen() seems not get the newly added content. So I wonder it does cache stuff somewhere, right?
0
python,urllib2,urlopen
2010-08-27T16:34:00.000
0
3,586,295
I find it hard to believe that urllib2 does not do caching, because in my case, upon restart of the program the data is refreshed. If the program is not restarted, the data appears to be cached forever. Also retrieving the same data from Firefox never returns stale data.
0
12,290
false
0
1
Does urllib2.urlopen() cache stuff?
3,936,916
1
2
0
1
0
0
1.2
1
I'm writing a game which requires users to log in to their accounts in order to be able to play. What's the best way of transmitting passwords from client to server and storing them? I'm using Python and Twisted, if that's of any relevance.
0
python,security,passwords,network-programming
2010-08-29T17:38:00.000
0
3,595,835
The best way is to authenticate via SSL/TLS. The best way of storing passwords is to store them hashed with some complex hash like sha1(sha1(password)+salt) with salt.
0
447
true
0
1
Handling Password Authentication over a Network
3,595,865
1
4
0
4
3
0
0.197375
0
I'm just starting out learning python (for webapp usage) but I'm confused as to the best way for using it with html files and dynamic data. I know php has the <?php ?> tags which are great - does python have something like this or equivalent, if not how should I be doing it?
0
python,web-applications
2010-08-30T00:19:00.000
0
3,597,143
There are a few php style python options out there. Mod_python used to ship with one, and spyce had an alternate implementation, but that modality is out of favor with pythonistas. Instead, use a templating language. Genshi and jinja2 are both popular, but there are lots to choose from. Since you are new to web programming with python, you would probably be best off choosing an entire framework get started. Django, turbogears, and cherrypy are a few to check out. These frameworks will all include all the tools you need to make a modern website, including a templating language.
0
1,597
false
1
1
PHP style inline tags for Python?
3,597,157
1
1
0
2
1
1
1.2
0
I'm hosting an IronPython engine instance in my C# (Silverlight 4) app to execute some Python scripts on the fly. These scripts can return values of either IronPython.Modules.PythonDateTime+datetime, IronPython.Modules.PythonDateTime+date or IronPython.Modules.PythonDateTime+time types. I need to convert these to System.DateTime values in C# without losing resolution. How do I do this?
0
silverlight,silverlight-4.0,ironpython,dynamic-language-runtime
2010-08-30T11:13:00.000
0
3,599,800
I don't think there's a good way to do this other than pulling the elements of the date time out from properties like year, month, day, etc... and constructing a new DateTime instance from those. You could file feature request on ironpython.codeplex.com to have an explicit conversion to DateTime. That's pretty trivial to implement for at least some of these because they're using a DateTime behind the scenes.
0
334
true
0
1
Type conversion from IronPython.Modules.PythonDateTime to System.DateTime
3,605,304
5
18
0
15
45
0
1
0
I would like to know the basic principles and etiquette of writing a well structured code.
0
python,matlab,structure
2010-08-30T20:09:00.000
0
3,603,858
Well, if you want it in layman's terms: I reccomend people to write the shortest readable program that works. There are a lot more rules about how to format code, name variables, design classes, separate responsibilities. But you should not forget that all of those rules are only there to make sure that your code is easy to check for errors, and to ensure it is maintainable by someone else than the original author. If keep the above reccomendation in mind, your progam will be just that.
0
3,967
false
0
1
Good practices in writing MATLAB code?
3,604,355
5
18
0
22
45
0
1.2
0
I would like to know the basic principles and etiquette of writing a well structured code.
0
python,matlab,structure
2010-08-30T20:09:00.000
0
3,603,858
These are the most important two things to keep in mind when you are writing code: Don't write code that you've already written. Don't write code that you don't need to write.
0
3,967
true
0
1
Good practices in writing MATLAB code?
3,604,376
5
18
0
2
45
0
0.022219
0
I would like to know the basic principles and etiquette of writing a well structured code.
0
python,matlab,structure
2010-08-30T20:09:00.000
0
3,603,858
Personally, I've found that I learned more about programming style from working through SICP which is the MIT Intro to Comp SCI text (I'm about a quarter of the way through.) Than any other book. That being said, If you're going to be working in Python, the Google style guide is an excellent place to start. I read somewhere that most programs (scripts anyways) should never be more than a couple of lines long. All the requisite functionality should be abstracted into functions or classes. I tend to agree.
0
3,967
false
0
1
Good practices in writing MATLAB code?
3,604,396
5
18
0
1
45
0
0.011111
0
I would like to know the basic principles and etiquette of writing a well structured code.
0
python,matlab,structure
2010-08-30T20:09:00.000
0
3,603,858
Make it readable, make it intuitive, make it understandable, and make it commented.
0
3,967
false
0
1
Good practices in writing MATLAB code?
3,607,452
5
18
0
2
45
0
0.022219
0
I would like to know the basic principles and etiquette of writing a well structured code.
0
python,matlab,structure
2010-08-30T20:09:00.000
0
3,603,858
Many good points have been made above. I definitely second all of the above. I would also like to add that spelling and consistency in coding be something you practice (and also in real life). I've worked with some offshore teams and though their English is pretty good, their spelling errors caused a lot of confusion. So for instance, if you need to look for some function (e.g., getFeedsFromDatabase) and they spell database wrong or something else, that can be a big or small headache, depending on how many dependencies you have on that particular function. The fact that it gets repeated over and over within the code will first off, drive you nuts, and second, make it difficult to parse. Also, keep up with consistency in terms of naming variables and functions. There are many protocols to go by but as long as you're consistent in what you do, others you work with will be able to better read your code and be thankful for it.
0
3,967
false
0
1
Good practices in writing MATLAB code?
3,604,559
1
2
0
0
0
0
1.2
0
Can Mechanize access sites being locally hosted by Apache?
0
python,mechanize
2010-08-30T20:12:00.000
1
3,603,883
Yes. It can use any URL available so long as it is reachable. Just make sure it's properly formatted!
0
257
true
1
1
Can python's mechanize use localhost sites?
3,603,922
1
3
0
0
0
0
1.2
0
Question is simple, i have a object file and i want to read the symbols of the object file via code. I am aware that the linux command "nm" would be able to do this, but i want to be able to do it inside code. Also note id like to do this either via C or Python. Regards Paul
0
python,c,linux
2010-08-31T08:21:00.000
1
3,607,254
On linux object files are written in ELF file format.So i think you have to start with understanding the ELF file format and how OS write object file using this format.That can give you a idea how you can read object file and symbol table by your own program.To get some initial idea you can look into the source code of readelf tool.
0
1,506
true
0
1
How to read symbols of an object file using C
3,607,298
1
2
0
6
5
1
1.2
0
Newbie question: Python 2.6, Ubuntu 10.04, I can import both pycurl and curl, the former having different names for functions (set_option vs. setopt). What's the difference between the two modules?
0
python,ubuntu,curl,pycurl
2010-08-31T14:25:00.000
0
3,609,952
curl is a module which uses pycurl. It provides the curl.Curl class which provides a high-level interface to the pycurl functions. I haven't found much documentation on how to use it, but reading /usr/share/pyshared/curl/__init__.py may make it pretty self-obvious. There are also some examples in /usr/share/doc/python-pycurl/examples which use curl.Curl.
0
1,716
true
0
1
What's the difference between pycurl and curl in python
3,609,988
3
3
0
3
4
1
0.197375
0
I'm trying to get a sense of the similarities between languages in syntax. How similar are Python, jQuery and C? I started programming in Actionscript 3 and then moved on to Javascript , then went on and learned Prototype, and then I started using jQuery and found that the syntax is very different. So is jQuery more like C and Python?
0
javascript,jquery,python,c,syntax
2010-09-01T04:54:00.000
0
3,615,122
For jQuery, the answer is pretty simple: jQuery isn't a language, therefore it doesn't have syntax. For Python and C, the answer from a high-level point of view is also very simple: Python's syntax is directly inspired by C's syntax. (Or more precisely, both Python's and C's syntax are inspired by ALGOL's syntax.) There is really only one significant difference from a high-level point of view: C uses opening and closing curly braces to delimit blocks, Python uses indentation. Otherwise, the two high-level syntaxes are almost the same: both have unary and binary operators, even with similar precedence (unline Smalltalk, for example, which doesn't have operators), both distinguish between statements and expressions (unlike Ruby, for example, which doesn't have statements), both use semicolons between statements (although technically, the semicolon is a statement terminator in C and a statement separator in Python), both use similar syntax for numeric literals and string literals as well as array/list indexing. There are a couple of syntactic differences related to the different semantics: in Python, variables are untyped (only objects are typed), so there is no type annotation syntax for variable declarations (in fact, there is no syntax for variable declarations at all). There is syntax for type annotations of function parameters and function return values, but in Python the types come after the parameter name, and the type annotations are optional. With variables being untyped, the concept of type casting doesn't make sense, so there is no syntax for that. Neither is there any pointer-related syntax, since Python doesn't have those. Python has a couple more literals than C: lists, sets, dictionaries, in particular. However, they follow in the C tradition: in C, an array is declared and indexed using square brackets, so Python uses square brackets for array literals.
0
2,839
false
0
1
How similar are Python, jQuery, C syntax wise?
3,618,018
3
3
0
3
4
1
0.197375
0
I'm trying to get a sense of the similarities between languages in syntax. How similar are Python, jQuery and C? I started programming in Actionscript 3 and then moved on to Javascript , then went on and learned Prototype, and then I started using jQuery and found that the syntax is very different. So is jQuery more like C and Python?
0
javascript,jquery,python,c,syntax
2010-09-01T04:54:00.000
0
3,615,122
Syntax wise, JavaScript (the language jQuery is implemented in) is similar to C. Python uses a different syntax which does not rely on semicolons and braces, but instead on indentation. Semantically, JavaScript is closer to Python, so this would be easier to learn. I don't understand how you "moved" from ActionScript 3 to JavaScript to Prototype; ActionScript has the same syntax and is also otherwise very similar to JavaScript, and Protoype/jQuery are just applications written in JavaScript (so it's the same language, but different frameworks!)
0
2,839
false
0
1
How similar are Python, jQuery, C syntax wise?
3,615,135
3
3
0
8
4
1
1.2
0
I'm trying to get a sense of the similarities between languages in syntax. How similar are Python, jQuery and C? I started programming in Actionscript 3 and then moved on to Javascript , then went on and learned Prototype, and then I started using jQuery and found that the syntax is very different. So is jQuery more like C and Python?
0
javascript,jquery,python,c,syntax
2010-09-01T04:54:00.000
0
3,615,122
C is much different from the languages you've asked about. Remember that C isn't an interpreted language and will not be treated as such in your code. In short, you're up for a lot more material to learn --while dealing with C-- in terms of things like memory management and semantics than the other languages. In regards to syntax: You'll find that if you're writing code in any language other than Lisp, brainfuck, or some other non-intuitive language (not claiming that C is, but in comparison, certainly), the syntax isn't too much of a variable. There are some differences, but nothing that should be considered too abstract. In C, you have to worry about things like pointers and whatnot which is a pain, but I think the difference is more-so about memory management than syntax. You mostly have to worry about the differences in usages of semicolons and whatnot. You'll find that Python is like writing English sentences, or at least writing pseudocode with constraints, which makes it significantly easier than C. Additionally, I wouldn't consider jQuery a language on its own. It's an extension of a language though, just as STL might be considered a particular type of extension to C++. Good luck.
0
2,839
true
0
1
How similar are Python, jQuery, C syntax wise?
3,615,482
1
2
0
4
0
0
1.2
1
I try to move email from mailbox's gmail to another one, Just curious that UID of each email will change when move to new mailbox ?
0
python,imap,imaplib
2010-09-01T06:37:00.000
0
3,615,561
Yes of course the UID is changed when you do move operation. the new UID for that mail will be the next UID from the destination folder. (i.e if the last mail UID of the destination folder is : 9332 , then the UID of the move email will be 9333) Note: UID is changed but the Message-Id will not be changed during any operation on that mail)
0
5,836
true
0
1
About IMAP UID with imaplib
3,636,059
3
4
0
5
4
0
0.244919
0
I'm planning to use Python to develop a web application. Anybody has any idea about any accelerator for python? (something like eAccelerator or apc for php) if not, is there any way to cache the pre-compiled python bytecode ? Any idea about the performance comparison between python and php (assuming db/network latencies are same) Thanks in advance.
0
php,python,accelerator
2010-09-01T14:22:00.000
0
3,619,063
As long as you do trivial amounts of work in your "main script" (the one you directly invoke with python and which gets a __name__ of __main__) you need not worry about "caching the pre-compiled python bytecode": when you import foo, foo.py gets saved to disk (same directory) as foo.pyc, as long as that directory is writable by you, so the already-cheap compilation to bytecode happens once and "forever after" Python will load foo.pyc directly in every new process that does import foo -- within a single process, every import foo except the first one is just a fast lookup into a dictionary in memory (the sys.module dictionary). A core performance idea in Python: makes sure every bit of substantial code happens within def statements in modules -- don't have any at module top level, in the main script, or esp. within exec and eval statements/expressions!-). I have no benchmarks for PHP vs Python, but I've noticed that Python keeps getting optimized pretty noticeably with every new release, so make sure you compare a recent release (idealy 2.7, at least 2.6) if you want to see "the fastes Python". If you don't find it fast enough yet, cython (a Python dialect designed to compile directly into C, and thence into machine code, with some limitations) is today the simplest way to selectively optimize those modules which profiling shows you need it.
0
1,571
false
0
1
Python accelerator
3,619,178
3
4
0
3
4
0
1.2
0
I'm planning to use Python to develop a web application. Anybody has any idea about any accelerator for python? (something like eAccelerator or apc for php) if not, is there any way to cache the pre-compiled python bytecode ? Any idea about the performance comparison between python and php (assuming db/network latencies are same) Thanks in advance.
0
php,python,accelerator
2010-09-01T14:22:00.000
0
3,619,063
Others have mentioned Python byte code files, but that is largely irrelevant. This is because hosting mechanisms for Python, with the exception of CGI, keep the Python web Application in memory between requests. This is different to PHP which effectively throws away the application between requests. As such, Python doesn't need an accelerator as the way Python web hosting mechanisms work avoids the problems that PHP has.
0
1,571
true
0
1
Python accelerator
3,622,927
3
4
0
8
4
0
1
0
I'm planning to use Python to develop a web application. Anybody has any idea about any accelerator for python? (something like eAccelerator or apc for php) if not, is there any way to cache the pre-compiled python bytecode ? Any idea about the performance comparison between python and php (assuming db/network latencies are same) Thanks in advance.
0
php,python,accelerator
2010-09-01T14:22:00.000
0
3,619,063
There's a trick to this. It's called mod_wsgi. The essence of it works like this. For "static" content (.css, .js, images, etc.) put them in a directory so they're served by Apache, without your Python program knowing they were sent. For "dynamic" content (the main HTML page itself) you use mod_wsgi to fork a "back-end" process that runs outside of Apache. This is faster than PHP because now several things are going on at once. Apache has dispatched the request to a backend process and then moved on to handle the next request while the backend is still running the first one. Also, when you've sent your HTML page, the follow-on requests are handled by Apache without your Python program knowing or caring what's going on. This leads to huge speedups. Nothing to do with the speed of Python. Everything to do with the overall architecture.
0
1,571
false
0
1
Python accelerator
3,619,244
6
7
0
0
11
1
0
0
I am from Java world and I wonder what is so great about dynamic typing in Python besides missing errors while compiling the code? Do you like Python's typing? Do you have an example where it helped in a big project? Isn't it a bit error prone?
0
java,python,static-typing,dynamic-typing
2010-09-01T19:07:00.000
0
3,621,297
It's a load off your mind. You can think the color red as "Red" (a constant) as "255, 0, 0" (a tuple) or "#FF0000" (a string): three different formats, that would require three different types, or complex lookup and conversion methods in Java. It makes code simpler.
0
2,330
false
0
1
How to deal with Python ~ static typing?
3,621,365
6
7
0
0
11
1
0
0
I am from Java world and I wonder what is so great about dynamic typing in Python besides missing errors while compiling the code? Do you like Python's typing? Do you have an example where it helped in a big project? Isn't it a bit error prone?
0
java,python,static-typing,dynamic-typing
2010-09-01T19:07:00.000
0
3,621,297
For example, you can write functions to which you can pass an integer as well as a string or a list or a dictionary or whatever else, and it will be able to transparently handle all of them in appropriate ways (or throw an exception if it cannot handle the type). You can do things like that in other languages, too, but usually you have to resort to (ab)use things like pointers, references or typecasts, which opens holes for programming errors, and it's just plain ugly.
0
2,330
false
0
1
How to deal with Python ~ static typing?
3,621,395
6
7
0
5
11
1
0.141893
0
I am from Java world and I wonder what is so great about dynamic typing in Python besides missing errors while compiling the code? Do you like Python's typing? Do you have an example where it helped in a big project? Isn't it a bit error prone?
0
java,python,static-typing,dynamic-typing
2010-09-01T19:07:00.000
0
3,621,297
Do you like it in Python? It's part of Python. Liking it in Python is silly. Do you have an example where it helped in a big project? Yes. Every single day I rejoice that I can make changes and -- because of Duck typing -- they are reasonably localized, pass all the unit tests, pass all the integration tests, and nothing is disrupted elsewhere. If this was Java, the changes would require endless refactoring to pull interfaces out of classes so that I could introduce variations that were still permitted under Java's static type checking. Doesn't it a bit error prone? Not any more than static typing is. A simple unit test confirms that the objects conform to the expected features. It's easy to write a class in Java that (a) passes compile-time checks and (b) crashes horribly at run time. Casts are a good way to do this. Failing to meet the classes intent is a common thing -- a class may compile but still not work.
0
2,330
false
0
1
How to deal with Python ~ static typing?
3,621,720
6
7
0
2
11
1
0.057081
0
I am from Java world and I wonder what is so great about dynamic typing in Python besides missing errors while compiling the code? Do you like Python's typing? Do you have an example where it helped in a big project? Isn't it a bit error prone?
0
java,python,static-typing,dynamic-typing
2010-09-01T19:07:00.000
0
3,621,297
A lot of patterns (e.g. from GoF) are unnecessary or can be implemented with less efforts in dynamic-typed languages with functional flavor. In fact, a lot of patterns are "built-in" into python so if you write short and 'pythonic' code you will get all the benefits for free. You don't need Iterator, Observer, Strategy, Factory Method, Abstract Factory, and a bunch of other patterns that are common in Java or C++. This means less code to write and (much more important) less code to read, understand and support. I think this is the main benefit of languages like python. And in my opinion this greatly outweighs the absence of static typing. Type-related errors are not often in python code and they are easy to catch with simple functional tests (and such tests are easier to write in python than in java for sure).
0
2,330
false
0
1
How to deal with Python ~ static typing?
3,621,952
6
7
0
13
11
1
1
0
I am from Java world and I wonder what is so great about dynamic typing in Python besides missing errors while compiling the code? Do you like Python's typing? Do you have an example where it helped in a big project? Isn't it a bit error prone?
0
java,python,static-typing,dynamic-typing
2010-09-01T19:07:00.000
0
3,621,297
I suspect that the vast majority of non-trivial Java programs have dynamic typing in them. Every time in Java that you do a cast from Object to an explicit type you are doing dynamic type checking - this includes every use of a collection class before generics were introduced in 1.5. Actually Java generics can still defer some type checking until runtime. Every time you use Java reflection you are doing dynamic type checking. This includes mapping from a class or method name in an text file to a real class or method - e.g. every time you use a Spring XML configuration file. Does this make Java programs fragile and error prone? Do Java programmers spend a significant part of their time having to track down and fix problems with incorrect dynamic typing? Probably not - and neither do Python programmers. Some of the advantages of dynamic typing: Greatly reduced reliance on inheritance. I have seen Java programs with massive inheritance trees. Python programs often use little or no inheritance, preferring to use duck typing. It is easy to write truly generic code. For example the min() and max() functions can take a sequence of any comparable type - integers, strings, floats, classes that have the appropriate comparison methods, lists, tuples etc. Less code. A huge proportion of Java code contributes nothing to solving the problem at hand - it is purely there to keep the type system happy. If a Python program is a fifth the size of the equivalent Java program then there is one fifth the code to write, maintain, read and understand. To put it another way, Python has a much higher signal to noise ratio. Faster development cycle. This goes hand in hand with less code - you spend less time thinking about types and classes and more time thinking about solving the problem you are working on. Little need for AOP. I think there are aspect oriented libraries for Python but I don't know of anyone that uses them, since for 99% of what you need AOP for you can do with decorators and dynamic object modification. The wide use of AspectJ in the Java world suggests to me that there are deficiencies in the core Java language that have to be compensated for with an external tool.
0
2,330
false
0
1
How to deal with Python ~ static typing?
3,621,904
6
7
0
0
11
1
0
0
I am from Java world and I wonder what is so great about dynamic typing in Python besides missing errors while compiling the code? Do you like Python's typing? Do you have an example where it helped in a big project? Isn't it a bit error prone?
0
java,python,static-typing,dynamic-typing
2010-09-01T19:07:00.000
0
3,621,297
As you're from the Java world, the obvious answer would be that it's great not to be forced to write all that stuff you are forced to write, just to keep Java's type system happy. Of course, there are other statically type checked languages that don't force you to write all that stuff that Java forces you to write. Even C# does type inference for local method variables! And there are other statically type checked languages that provide more compile time error checking than Java provides. (The less obvious answers for - what is so great about dynamic typing in Python? - probably require more understanding of Python to understand.)
0
2,330
false
0
1
How to deal with Python ~ static typing?
3,621,429
1
3
0
4
3
0
0.26052
0
I want a mercurial hook that will run JSLint/PyChecker/etc on all files that are modified. However, I do not have control over all hg clients, and want this to run on push to the master repository (which I have control), so a pretxnchangegroup hook on the master seems best. How can I get a list of all changesets that are in the changegroup that is going to be committed? I have seem other solutions that use a precommit hook, but these will not work for me because the clients may already have a commit that fails JSLint. In this case, they should be able to fix the errors in a new commit, and be able to push (both the bad and new commits) to the server successfully. The server just needs to check the most recent changeset on each branch, of every file that was modified in the changegroup.
0
python,mercurial,hook,mercurial-hook
2010-09-01T19:28:00.000
0
3,621,463
You're right that you want a pretxnchangegroup hook, but you don't want to check all the new revisions -- because people will fix the errors you reject in subsequent changesets but if you're checking all changesets their work will never be accepted! Instead either just check all files in all the heads, or use the hg status --rev x:y syntax to get a list of the changed files between the revision you already have and the tip revision you're receiving, and check only those files only in the tip revision. If you really want the list of all revisions you'd use a revset ( hg help revsets ) new in version 1.6, but you really only want to check the results, not all the revisions that get you there.
0
2,726
false
0
1
Get list of changesets in a changegroup (mercurial python hook)
3,621,563
1
3
0
2
1
0
0.132549
0
i found out that my server is getting slower and slower. on command top i get response that i have a lot svcrack.py and svwar.py processes active. can you tell me what are those? thank you in advance!
0
python,apache
2010-09-02T07:10:00.000
0
3,624,521
as everyone else said, that's part of SIPVicious, of which I'm the original author. Your server got compromised (somehow) and is being used to scan and compromise PBX servers open on the internet. I would like more details about your case. Would be great if you could get in contact - [email protected] sandro
0
4,163
false
0
1
svcrack.py and svwar.py
3,624,825
2
2
0
1
1
1
0.099668
0
While PyDev turns out to be a great IDE for python, especially if you are a former Java developer accustomed to all the eclipse ubercool navigation, it still lacks some features that Wing has, like GUI for running python unit-tests. I know Wing has some "personalities" of other editors: vi, emacs, Visual Studio, ... Unfortunately, Eclipse is not one of them. Before I start configuring all the keys myself, creating a keymap.eclipse file, etc. (seems like it's gonna take ages), I wanted to know if no one already configured it and can share it with the rest of the world. Thanks!
0
python,eclipse,wing-ide
2010-09-02T15:54:00.000
1
3,628,847
I've added an experimental one in version 4.1.3
0
139
false
0
1
Is there an Eclipse personality settings for Wing IDE?
9,213,010
2
2
0
0
1
1
1.2
0
While PyDev turns out to be a great IDE for python, especially if you are a former Java developer accustomed to all the eclipse ubercool navigation, it still lacks some features that Wing has, like GUI for running python unit-tests. I know Wing has some "personalities" of other editors: vi, emacs, Visual Studio, ... Unfortunately, Eclipse is not one of them. Before I start configuring all the keys myself, creating a keymap.eclipse file, etc. (seems like it's gonna take ages), I wanted to know if no one already configured it and can share it with the rest of the world. Thanks!
0
python,eclipse,wing-ide
2010-09-02T15:54:00.000
1
3,628,847
Unfortunately, there's no Eclipse personality.
0
139
true
0
1
Is there an Eclipse personality settings for Wing IDE?
3,629,793
2
4
0
-1
6
1
-0.049958
0
I need to pull from hundreds of pop3 email accounts, and i want to build a robust server to do this. Would twisted be a good choice for this type of project? Right now a simple prototype would be to pull from a single pop3 account, then it would pull from many but it would be a serialized process. I want to create a server that has multiple threads so it can do things at the same time.
0
python,multithreading,twisted
2010-09-02T16:22:00.000
0
3,629,088
A word of caution with twisted, while twisted is very robust I've found that spinning up a hundred threads using the code examples available in documentation is a recipe for race conditions and deadlocks. My suggestion is try twisted but have the stdlib multithreading module waiting in the wings if twisted becomes unmanageable. I have had good success with a producer consumer model using the aforementioned library.
0
2,134
false
0
1
Would twisted be a good choice for building a multi-threaded server?
3,629,349
2
4
0
0
6
1
0
0
I need to pull from hundreds of pop3 email accounts, and i want to build a robust server to do this. Would twisted be a good choice for this type of project? Right now a simple prototype would be to pull from a single pop3 account, then it would pull from many but it would be a serialized process. I want to create a server that has multiple threads so it can do things at the same time.
0
python,multithreading,twisted
2010-09-02T16:22:00.000
0
3,629,088
It is a good choice for a server but from your description you are acutally looking for a multithreaded POP client. Twisted is made for reacting to events like incoming requests, you need to send requests, so in this case I fear twisted to be of limited value.
0
2,134
false
0
1
Would twisted be a good choice for building a multi-threaded server?
3,629,187
1
2
0
-1
0
1
-0.099668
1
I am attempting to use the tweepy api to make a twitter function and I have two issues. I have little experience with the terminal and Python in general. 1) It installed properly with Python 2.6, however I can't use it or install it with Python 3.1. When I attempt to install the module in 3.1 it gives me an error that there is no module setuptools. Originally I thought that perhaps I was unable to use tweepy module with 3.1, however in the readme it says "Python 3 branch (3.1)", which I assume means it is compatible. When I searched for the setuptools module, which I figured I could load into the new version, there was only modules for up to Python 2.7. How would I install the Tweepy api properly on Python 3.1? 2) My default Python when run from terminal is 2.6.1 and I would like to make it 3.1 so I don't have to type python3.1.
0
python,tweepy
2010-09-02T22:39:00.000
0
3,631,828
Update: The comments below have some solid points against this technique. 2) What OS are you running? Generally, there is a symlink somewhere in your system, which points from 'python' to 'pythonx.x', where x.x is the version number preferred by your operating system. On Linux, there is a symlink /usr/bin/python, which points to (on Ubuntu 10.04) /usr/bin/python2.6 on a standard installation. Just manually change the current link to point to the python3.1 binary, and you are fine.
0
1,565
false
0
1
Python defaults and using tweepy api
3,631,888