A_Id
int64
518
76.6M
AnswerCount
int64
1
64
Question
stringlengths
15
29.1k
Available Count
int64
1
31
Tags
stringlengths
6
105
Q_Id
int64
337
75M
Answer
stringlengths
6
11.6k
is_accepted
bool
2 classes
CreationDate
stringlengths
19
23
ViewCount
int64
6
6.81M
Users Score
int64
-42
1.15k
Score
float64
-1
1.2
Title
stringlengths
11
150
Q_Score
int64
0
6.79k
3,179,675
19
According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other?
12
python,coding-style
56,011
I use double quotes because I have been doing so for years in most languages (C++, Java, VB…) except Bash, because I also use double quotes in normal text and because I'm using a (modified) non-English keyboard where both characters require the shift key.
false
2008-09-11 08:18:55.293
712,544
-1
-0.010526
Single quotes vs. double quotes in Python
718
145,149
19
According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other?
12
python,coding-style
56,011
Personally I stick with one or the other. It doesn't matter. And providing your own meaning to either quote is just to confuse other people when you collaborate.
false
2008-09-11 08:18:55.293
712,544
3
0.031568
Single quotes vs. double quotes in Python
718
103,212
2
We're at the beginning of a new ERP-ish client-server application, developed as a Python rich client. We're currently evaluating Dabo as our main framework and it looks quite nice and easy to use, but I was wondering, has anyone used it for medium-to-big sized projects? Thanks for your time!
1
python,erp,dabo
56,417
I have no Dabo experience at all but this question is on the top of the list fo such a long time that I decided to give it a shot: Framework selection Assumptions: medium-to-big project: we're talking about a team of more than 20 people working on something for about a year for the first phase. This is usually an expensive and very important effort for the client. this project will have significant amount of users (around a hundred) so performance is essential it's an ERP project so the application will work with large amounts of information you have no prior Dabo experience in your team Considerations: I could not open Dabo project site right now. There seems to be some server problem. That alone would make me think twice about using it for a big project. It's not a well-known framework. Typing Dabo in Google returns almost no useful results, it does not have a Wikipedia page, all-in-all it's quite obscure. It means that when you will have problems with it (and you will have problems with it) you will have almost no place to go. Your question was unanswered for 8 days on SO, this alone would make me re-consider. If you base your project on an obscure technology you have no previous experience with - it's a huge risk. You don't have people who know that framework in your team. It means that you have to learn it to get any results at all and to master it will require quite significant amount of time. You will have to factor that time into your project plan. Do you really need it? What does this framework give you that you cannot do yourself? Quite a lot of time my team tried to use some third-party component or tool only to find that building a custom one would be faster than dealing with third-party problems and limitations. There are brilliant tools available to people nowadays and we would be lost without them - but you have to carefully consider if this tool is one of them Dabo project version is 0.84. Do you know if they spend time optimising their code for performance at this stage? Did you run any tests to see it will sustain the load you have in your NFRs. Hope that helps :) Good luck with your project
false
2008-09-11 12:29:09.013
4,033
2
0.197375
Anyone used Dabo for a medium-big project?
21
58,296
9
When I call socket.getsockname() on a socket object, it returns a tuple of my machine's internal IP and the port. However, I would like to retrieve my external IP. What's the cheapest, most efficient manner of doing this?
2
python,sockets
58,294
This isn't possible without cooperation from an external server, because there could be any number of NATs between you and the other computer. If it's a custom protocol, you could ask the other system to report what address it's connected to.
true
2008-09-12 04:21:51.237
19,360
9
1.2
How do I get the external IP of a socket in Python?
10
256,358
9
When I call socket.getsockname() on a socket object, it returns a tuple of my machine's internal IP and the port. However, I would like to retrieve my external IP. What's the cheapest, most efficient manner of doing this?
2
python,sockets
58,294
import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("msn.com",80)) s.getsockname()
false
2008-09-12 04:21:51.237
19,360
2
0.044415
How do I get the external IP of a socket in Python?
10
7,610,441
8
Been scouring the net for something like firewatir but for python. I'm trying to automate firefox on linux. Any suggestions?
2
python,linux,firefox,ubuntu,automation
60,152
I would suggest you to use Selenium instead of Mechanize/Twill because Mechanize would fail while handling Javascript.
false
2008-09-12 23:28:16.830
21,896
1
0.024995
Automate firefox with python?
12
60,218
8
Been scouring the net for something like firewatir but for python. I'm trying to automate firefox on linux. Any suggestions?
2
python,linux,firefox,ubuntu,automation
60,152
The languages of choice of Firefox is Javascript. Unless you have a specific requirement that requires Python, I would advice you to use that.
false
2008-09-12 23:28:16.830
21,896
0
0
Automate firefox with python?
12
60,431
2
If all of my __init__.py files are empty, do I have to store them into version control, or is there a way to make distutils create empty __init__.py files during installation?
1
python,version-control,distutils
60,352
In Python, __init__.py files actually have a meaning! They mean that the folder they are in is a Python module. As such, they have a real role in your code and should most probably be stored in Version Control. You could well imagine a folder in your source tree that is NOT a Python module, for example a folder containing only resources (e.g. images) and no code. That folder would not need to have a __init__.py file in it. Now how do you make the difference between folders where distutils should create those files and folders where it should not ?
false
2008-09-13 05:51:17.097
1,565
7
1
Can distutils create empty __init__.py files?
0
60,945
4
What is the best way to start developing Windows Mobile Professional applications in Python? Is there a reasonable SDK including an emulator? Is it even possible without doing excessive amount of underlaying Windows API calls for UI for instance?
1
python,windows-mobile
60,446
(I used to write customer apps for Windows Mobile.) Forget about python. Even if it's technically possible: your app will be big (you'll have to bundle the whole python runtime with your app) your app will use lots of memory (python is a memory hog, relative to C/C++) your app will be slow you wont find any documentation or discussion groups to help you when you (inevitably) encounter problems Go with C/C++ (or C#). Visual Studio 2005/2008 have decent tools for those (SDK for winmo built-in, debugging on the emulator or device connected through USB), the best documentation is for those technologies plus there are active forums/discussion groups/mailing lists where you can ask for help.
false
2008-09-13 09:56:04.653
7,815
9
1
Windows Mobile development in Python
4
103,211
11
Is it possible to retrieve items from a Python dictionary in the order that they were inserted?
4
python,dictionary
60,848
It's not possible unless you store the keys in a separate list for referencing later.
false
2008-09-13 20:38:05.467
47,709
0
0
How do you retrieve items from a dictionary in the order that they're inserted?
65
65,991
11
Is it possible to retrieve items from a Python dictionary in the order that they were inserted?
4
python,dictionary
60,848
Or, just make the key a tuple with time.now() as the first field in the tuple. Then you can retrieve the keys with dictname.keys(), sort, and voila! Gerry
false
2008-09-13 20:38:05.467
47,709
5
0.090659
How do you retrieve items from a dictionary in the order that they're inserted?
65
60,852
11
Is it possible to retrieve items from a Python dictionary in the order that they were inserted?
4
python,dictionary
60,848
You can't do this with the base dict class -- it's ordered by hash. You could build your own dictionary that is really a list of key,value pairs or somesuch, which would be ordered.
false
2008-09-13 20:38:05.467
47,709
5
0.090659
How do you retrieve items from a dictionary in the order that they're inserted?
65
64,266
11
Is it possible to retrieve items from a Python dictionary in the order that they were inserted?
4
python,dictionary
60,848
if you don't need the dict functionality, and only need to return tuples in the order you've inserted them, wouldn't a queue work better?
false
2008-09-13 20:38:05.467
47,709
-1
-0.01818
How do you retrieve items from a dictionary in the order that they're inserted?
65
63,645
18
If you're writing a library, or an app, where do the unit test files go? It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. Is there a best practice here?
4
python,unit-testing,code-organization
61,151
When writing a package called "foo", I will put unit tests into a separate package "foo_test". Modules and subpackages will then have the same name as the SUT package module. E.g. tests for a module foo.x.y are found in foo_test.x.y. The __init__.py files of each testing package then contain an AllTests suite that includes all test suites of the package. setuptools provides a convenient way to specify the main testing package, so that after "python setup.py develop" you can just use "python setup.py test" or "python setup.py test -s foo_test.x.SomeTestSuite" to the just a specific suite.
false
2008-09-14 05:41:11.810
112,049
0
0
Where do the Python unit tests go?
545
61,820
18
If you're writing a library, or an app, where do the unit test files go? It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. Is there a best practice here?
4
python,unit-testing,code-organization
61,151
In C#, I've generally separated the tests into a separate assembly. In Python -- so far -- I've tended to either write doctests, where the test is in the docstring of a function, or put them in the if __name__ == "__main__" block at the bottom of the module.
false
2008-09-14 05:41:11.810
112,049
1
0.011111
Where do the Python unit tests go?
545
61,518
18
If you're writing a library, or an app, where do the unit test files go? It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. Is there a best practice here?
4
python,unit-testing,code-organization
61,151
I've recently started to program in Python, so I've not really had chance to find out best practice yet. But, I've written a module that goes and finds all the tests and runs them. So, I have: app/ appfile.py test/ appfileTest.py I'll have to see how it goes as I progress to larger projects.
false
2008-09-14 05:41:11.810
112,049
-2
-0.022219
Where do the Python unit tests go?
545
61,168
18
If you're writing a library, or an app, where do the unit test files go? It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. Is there a best practice here?
4
python,unit-testing,code-organization
61,151
I don't believe there is an established "best practice". I put my tests in another directory outside of the app code. I then add the main app directory to sys.path (allowing you to import the modules from anywhere) in my test runner script (which does some other stuff as well) before running all the tests. This way I never have to remove the tests directory from the main code when I release it, saving me time and effort, if an ever so tiny amount.
false
2008-09-14 05:41:11.810
112,049
13
1
Where do the Python unit tests go?
545
61,570
1
What is the best available method for developing a spell check engine (for example, with aspell_python), that works with apache mod_python? apache 2.0.59+RHEL4+mod_python+aspell_python seems to crash. Is there any alternative to using aspell_python?
1
spell-checking,mod-python,aspell
61,556
Looks like RHEL4 is the culprit. Works well on Fedore 7 (the version of apache is newer and there is no crash)
false
2008-09-14 18:58:51.003
238
1
0.197375
Spell Checking Service with python using mod_python
0
62,592
16
What is the easiest way to compare strings in Python, ignoring case? Of course one can do (str1.lower() <= str2.lower()), etc., but this created two additional temporary strings (with the obvious alloc/g-c overheads). I guess I'm looking for an equivalent to C's stricmp(). [Some more context requested, so I'll demonstrate with a trivial example:] Suppose you want to sort a looong list of strings. You simply do theList.sort(). This is O(n * log(n)) string comparisons and no memory management (since all strings and list elements are some sort of smart pointers). You are happy. Now, you want to do the same, but ignore the case (let's simplify and say all strings are ascii, so locale issues can be ignored). You can do theList.sort(key=lambda s: s.lower()), but then you cause two new allocations per comparison, plus burden the garbage-collector with the duplicated (lowered) strings. Each such memory-management noise is orders-of-magnitude slower than simple string comparison. Now, with an in-place stricmp()-like function, you do: theList.sort(cmp=stricmp) and it is as fast and as memory-friendly as theList.sort(). You are happy again. The problem is any Python-based case-insensitive comparison involves implicit string duplications, so I was expecting to find a C-based comparisons (maybe in module string). Could not find anything like that, hence the question here. (Hope this clarifies the question).
4
python,string,case-insensitive
62,567
I'm pretty sure you either have to use .lower() or use a regular expression. I'm not aware of a built-in case-insensitive string comparison function.
false
2008-09-15 12:57:10.677
109,190
0
0
Ignore case in Python strings
52
62,652
16
What is the easiest way to compare strings in Python, ignoring case? Of course one can do (str1.lower() <= str2.lower()), etc., but this created two additional temporary strings (with the obvious alloc/g-c overheads). I guess I'm looking for an equivalent to C's stricmp(). [Some more context requested, so I'll demonstrate with a trivial example:] Suppose you want to sort a looong list of strings. You simply do theList.sort(). This is O(n * log(n)) string comparisons and no memory management (since all strings and list elements are some sort of smart pointers). You are happy. Now, you want to do the same, but ignore the case (let's simplify and say all strings are ascii, so locale issues can be ignored). You can do theList.sort(key=lambda s: s.lower()), but then you cause two new allocations per comparison, plus burden the garbage-collector with the duplicated (lowered) strings. Each such memory-management noise is orders-of-magnitude slower than simple string comparison. Now, with an in-place stricmp()-like function, you do: theList.sort(cmp=stricmp) and it is as fast and as memory-friendly as theList.sort(). You are happy again. The problem is any Python-based case-insensitive comparison involves implicit string duplications, so I was expecting to find a C-based comparisons (maybe in module string). Could not find anything like that, hence the question here. (Hope this clarifies the question).
4
python,string,case-insensitive
62,567
You could subclass str and create your own case-insenstive string class but IMHO that would be extremely unwise and create far more trouble than it's worth.
false
2008-09-15 12:57:10.677
109,190
-1
-0.012499
Ignore case in Python strings
52
62,983
16
What is the easiest way to compare strings in Python, ignoring case? Of course one can do (str1.lower() <= str2.lower()), etc., but this created two additional temporary strings (with the obvious alloc/g-c overheads). I guess I'm looking for an equivalent to C's stricmp(). [Some more context requested, so I'll demonstrate with a trivial example:] Suppose you want to sort a looong list of strings. You simply do theList.sort(). This is O(n * log(n)) string comparisons and no memory management (since all strings and list elements are some sort of smart pointers). You are happy. Now, you want to do the same, but ignore the case (let's simplify and say all strings are ascii, so locale issues can be ignored). You can do theList.sort(key=lambda s: s.lower()), but then you cause two new allocations per comparison, plus burden the garbage-collector with the duplicated (lowered) strings. Each such memory-management noise is orders-of-magnitude slower than simple string comparison. Now, with an in-place stricmp()-like function, you do: theList.sort(cmp=stricmp) and it is as fast and as memory-friendly as theList.sort(). You are happy again. The problem is any Python-based case-insensitive comparison involves implicit string duplications, so I was expecting to find a C-based comparisons (maybe in module string). Could not find anything like that, hence the question here. (Hope this clarifies the question).
4
python,string,case-insensitive
62,567
For occasional or even repeated comparisons, a few extra string objects shouldn't matter as long as this won't happen in the innermost loop of your core code or you don't have enough data to actually notice the performance impact. See if you do: doing things in a "stupid" way is much less stupid if you also do it less. If you seriously want to keep comparing lots and lots of text case-insensitively you could somehow keep the lowercase versions of the strings at hand to avoid finalization and re-creation, or normalize the whole data set into lowercase. This of course depends on the size of the data set. If there are a relatively few needles and a large haystack, replacing the needles with compiled regexp objects is one solution. If It's hard to say without seeing a concrete example.
false
2008-09-15 12:57:10.677
109,190
0
0
Ignore case in Python strings
52
65,834
16
What is the easiest way to compare strings in Python, ignoring case? Of course one can do (str1.lower() <= str2.lower()), etc., but this created two additional temporary strings (with the obvious alloc/g-c overheads). I guess I'm looking for an equivalent to C's stricmp(). [Some more context requested, so I'll demonstrate with a trivial example:] Suppose you want to sort a looong list of strings. You simply do theList.sort(). This is O(n * log(n)) string comparisons and no memory management (since all strings and list elements are some sort of smart pointers). You are happy. Now, you want to do the same, but ignore the case (let's simplify and say all strings are ascii, so locale issues can be ignored). You can do theList.sort(key=lambda s: s.lower()), but then you cause two new allocations per comparison, plus burden the garbage-collector with the duplicated (lowered) strings. Each such memory-management noise is orders-of-magnitude slower than simple string comparison. Now, with an in-place stricmp()-like function, you do: theList.sort(cmp=stricmp) and it is as fast and as memory-friendly as theList.sort(). You are happy again. The problem is any Python-based case-insensitive comparison involves implicit string duplications, so I was expecting to find a C-based comparisons (maybe in module string). Could not find anything like that, hence the question here. (Hope this clarifies the question).
4
python,string,case-insensitive
62,567
You could translate each string to lowercase once --- lazily only when you need it, or as a prepass to the sort if you know you'll be sorting the entire collection of strings. There are several ways to attach this comparison key to the actual data being sorted, but these techniques should be addressed in a separate issue. Note that this technique can be used not only to handle upper/lower case issues, but for other types of sorting such as locale specific sorting, or "Library-style" title sorting that ignores leading articles and otherwise normalizes the data before sorting it.
false
2008-09-15 12:57:10.677
109,190
0
0
Ignore case in Python strings
52
63,094
22
I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off? I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?
16
python
63,086
No. Indentation-as-grammar is an integral part of the Python language, for better and worse.
false
2008-09-15 13:55:14.483
15,517
37
1
Is there a way around coding in Python without the tab, indent & whitespace criteria?
10
63,819
22
I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off? I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?
16
python
63,086
I find it hard to understand when people flag this as a problem with Python. I took to it immediately and actually find it's one of my favourite 'features' of the language :) In other languages I have two jobs: 1. Fix the braces so the computer can parse my code 2. Fix the indentation so I can parse my code. So in Python I have half as much to worry about ;-) (nb the only time I ever have problem with indendation is when Python code is in a blog and a forum that messes with the white-space but this is happening less and less as the apps get smarter)
false
2008-09-15 13:55:14.483
15,517
5
0.045423
Is there a way around coding in Python without the tab, indent & whitespace criteria?
10
63,216
22
I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off? I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?
16
python
63,086
I agree with justin and others -- pick a good editor and use spaces rather than tabs for indentation and the whitespace thing becomes a non-issue. I only recently started using Python, and while I thought the whitespace issue would be a real annoyance it turns out to not be the case. For the record I'm using emacs though I'm sure there are other editors out there that do an equally fine job. If you're really dead-set against it, you can always pass your scripts through a pre-processor but that's a bad idea on many levels. If you're going to learn a language, embrace the features of that language rather than try to work around them. Otherwise, what's the point of learning a new language?
false
2008-09-15 13:55:14.483
15,517
2
0.01818
Is there a way around coding in Python without the tab, indent & whitespace criteria?
10
63,095
22
I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off? I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?
16
python
63,086
I do not believe so, as Python is a whitespace-delimited language. Perhaps a text editor or IDE with auto-indentation would be of help. What are you currently using?
false
2008-09-15 13:55:14.483
15,517
3
0.027266
Is there a way around coding in Python without the tab, indent & whitespace criteria?
10
63,122
22
I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off? I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?
16
python
63,086
You should disable tab characters in your editor when you're working with Python (always, actually, IMHO, but especially when you're working with Python). Look for an option like "Use spaces for tabs": any decent editor should have one.
false
2008-09-15 13:55:14.483
15,517
3
0.027266
Is there a way around coding in Python without the tab, indent & whitespace criteria?
10
63,196
22
I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off? I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?
16
python
63,086
It's possible to write a pre-processor which takes randomly-indented code with pseudo-python keywords like "endif" and "endwhile" and properly indents things. I had to do this when using python as an "ASP-like" language, because the whole notion of "indentation" gets a bit fuzzy in such an environment. Of course, even with such a thing you really ought to indent sanely, at which point the conveter becomes superfluous.
false
2008-09-15 13:55:14.483
15,517
5
0.045423
Is there a way around coding in Python without the tab, indent & whitespace criteria?
10
68,061
22
I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off? I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?
16
python
63,086
Emacs! Seriously, its use of "tab is a command, not a character", is absolutely perfect for python development.
false
2008-09-15 13:55:14.483
15,517
10
1
Is there a way around coding in Python without the tab, indent & whitespace criteria?
10
1,515,244
22
I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off? I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?
16
python
63,086
Yes, there is a way. I hate these "no way" answers, there is no way until you discover one. And in that case, whatever it is worth, there is one. I read once about a guy who designed a way to code so that a simple script could re-indent the code properly. I didn't managed to find any links today, though, but I swear I read it. The main tricks are to always use return at the end of a function, always use pass at the end of an if or at the end of a class definition, and always use continue at the end of a while. Of course, any other no-effect instruction would fit the purpose. Then, a simple awk script can take your code and detect the end of block by reading pass/continue/return instructions, and the start of code with if/def/while/... instructions. Of course, because you'll develop your indenting script, you'll see that you don't have to use continue after a return inside the if, because the return will trigger the indent-back mechanism. The same applies for other situations. Just get use to it. If you are diligent, you'll be able to cut/paste and add/remove if and correct the indentations automagically. And incidentally, pasting code from the web will require you to understand a bit of it so that you can adapt it to that "non-classical" setting.
false
2008-09-15 13:55:14.483
15,517
0
0
Is there a way around coding in Python without the tab, indent & whitespace criteria?
10
63,111
22
I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off? I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?
16
python
63,086
No, there isn't. Indentation is syntax for Python. You can: Use tabnanny.py to check your code Use a syntax-aware editor that highlights such mistakes (vi does that, emacs I bet it does, and then, most IDEs do too) (far-fetched) write a preprocessor of your own to convert braces (or whatever block delimiters you love) into indentation
false
2008-09-15 13:55:14.483
15,517
3
0.027266
Is there a way around coding in Python without the tab, indent & whitespace criteria?
10
1,538,995
22
I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off? I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?
16
python
63,086
I'm surprised no one has mentioned IDLE as a good default python editor. Nice syntax colors, handles indents, has intellisense, easy to adjust fonts, and it comes with the default download of python. Heck, I write mostly IronPython, but it's so nice & easy to edit in IDLE and run ipy from a command prompt. Oh, and what is the big deal about whitespace? Most easy to read C or C# is well indented, too, python just enforces a really simple formatting rule.
false
2008-09-15 13:55:14.483
15,517
1
0.009091
Is there a way around coding in Python without the tab, indent & whitespace criteria?
10
63,289
22
I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off? I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?
16
python
63,086
Getting your indentation to work correctly is going to be important in any language you use. Even though it won't affect the execution of the program in most other languages, incorrect indentation can be very confusing for anyone trying to read your program, so you need to invest the time in figuring out how to configure your editor to align things correctly. Python is pretty liberal in how it lets you indent. You can pick between tabs and spaces (but you really should use spaces) and can pick how many spaces. The only thing it requires is that you are consistent which ultimately is important no matter what language you use.
false
2008-09-15 13:55:14.483
15,517
2
0.01818
Is there a way around coding in Python without the tab, indent & whitespace criteria?
10
69,064
22
I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off? I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?
16
python
63,086
Check the options of your editor or find an editor/IDE that allows you to convert TABs to spaces. I usually set the options of my editor to substitute the TAB character with 4 spaces, and I never run into any problems.
false
2008-09-15 13:55:14.483
15,517
0
0
Is there a way around coding in Python without the tab, indent & whitespace criteria?
10
64,899
22
I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off? I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?
16
python
63,086
In Python, indentation is a semantic element as well as providing visual grouping for readability. Both space and tab can indicate indentation. This is unfortunate, because: The interpretation(s) of a tab varies among editors and IDEs and is often configurable (and often configured). OTOH, some editors are not configurable but apply their own rules for indentation. Different sequences of spaces and tabs may be visually indistinguishable. Cut and pastes can alter whitespace. So, unless you know that a given piece of code will only be modified by yourself with a single tool and an unvarying config, you must avoid tabs for indentation (configure your IDE) and make sure that you are warned if they are introduced (search for tabs in leading whitespace). And you can still expect to be bitten now and then, as long as arbitrary semantics are applied to control characters.
false
2008-09-15 13:55:14.483
15,517
0
0
Is there a way around coding in Python without the tab, indent & whitespace criteria?
10
64,186
22
I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off? I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?
16
python
63,086
Many Python IDEs and generally-capable text/source editors can handle the whitespace for you. However, it is best to just "let go" and enjoy the whitespace rules of Python. With some practice, they won't get into your way at all, and you will find they have many merits, the most important of which are: Because of the forced whitespace, Python code is simpler to understand. You will find that as you read code written by others, it is easier to grok than code in, say, Perl or PHP. Whitespace saves you quite a few keystrokes of control characters like { and }, which litter code written in C-like languages. Less {s and }s means, among other things, less RSI and wrist pain. This is not a matter to take lightly.
false
2008-09-15 13:55:14.483
15,517
0
0
Is there a way around coding in Python without the tab, indent & whitespace criteria?
10
63,450
22
I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off? I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?
16
python
63,086
I was a bit reluctant to learn Python because of tabbing. However, I almost didn't notice it when I used Vim.
false
2008-09-15 13:55:14.483
15,517
1
0.009091
Is there a way around coding in Python without the tab, indent & whitespace criteria?
10
63,119
22
I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off? I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?
16
python
63,086
All of the whitespace issues I had when I was starting Python were the result mixing tabs and spaces. Once I configured everything to just use one or the other, I stopped having problems. In my case I configured UltraEdit & vim to use spaces in place of tabs.
false
2008-09-15 13:55:14.483
15,517
6
1
Is there a way around coding in Python without the tab, indent & whitespace criteria?
10
63,794
3
I'm hosting Python script with Python for Delphi components inside my Delphi application. I'd like to create background tasks which keep running by script. Is it possible to create threads which keep running even if the script execution ends (but not the host process, which keeps going on). I've noticed that the program gets stuck if the executing script ends and there is thread running. However if I'll wait until the thread is finished everything goes fine. I'm trying to use "threading" standard module for threads.
2
python,delphi
63,681
If a process dies all it's threads die with it, so a solution might be a separate process. See if creating a xmlrpc server might help you, that is a simple solution for interprocess communication.
false
2008-09-15 15:00:45.637
1,259
0
0
How create threads under Python for Delphi
1
63,767
3
I'm hosting Python script with Python for Delphi components inside my Delphi application. I'd like to create background tasks which keep running by script. Is it possible to create threads which keep running even if the script execution ends (but not the host process, which keeps going on). I've noticed that the program gets stuck if the executing script ends and there is thread running. However if I'll wait until the thread is finished everything goes fine. I'm trying to use "threading" standard module for threads.
2
python,delphi
63,681
Threads by definition are part of the same process. If you want them to keep running, they need to be forked off into a new process; see os.fork() and friends. You'll probably want the new process to end (via exit() or the like) immediately after spawning the script.
false
2008-09-15 15:00:45.637
1,259
0
0
How create threads under Python for Delphi
1
64,195
6
In Python is there any way to make a class, then make a second version of that class with identical dat,a but which can be changed, then reverted to be the same as the data in the original class? So I would make a class with the numbers 1 to 5 as the data in it, then make a second class with the same names for sections (or very similar). Mess around with the numbers in the second class then with one function then reset them to be the same as in the first class. The only alternative I've found is to make one aggravatingly long class with too many separate pieces of data in it to be readily usable.
2
python,class
64,141
Classes don't have values. Objects do. Is what you want basically a class that can reset an instance (object) to a set of default values? How about just providing a reset method, that resets the properties of your object to whatever is the default? I think you should simplify your question, or tell us what you really want to do. It's not at all clear.
false
2008-09-15 15:51:02.833
1,205
1
0.033321
Classes in Python
1
64,206
6
In Python is there any way to make a class, then make a second version of that class with identical dat,a but which can be changed, then reverted to be the same as the data in the original class? So I would make a class with the numbers 1 to 5 as the data in it, then make a second class with the same names for sections (or very similar). Mess around with the numbers in the second class then with one function then reset them to be the same as in the first class. The only alternative I've found is to make one aggravatingly long class with too many separate pieces of data in it to be readily usable.
2
python,class
64,141
I think you are confused. You should re-check the meaning of "class" and "instance". I think you are trying to first declare a Instance of a certain Class, and then declare a instance of other Class, use the data from the first one, and then find a way to convert the data in the second instance and use it on the first instance... I recommend that you use operator overloading to assign the data.
false
2008-09-15 15:51:02.833
1,205
1
0.033321
Classes in Python
1
67,769
8
I've googled around for this, but I still have trouble relating to what Django defines as "apps". Should I create a new app for each piece of functionality in a site, even though it uses models from the main project? Do you guys have good rule of thumb of when to split off a new app, and when to keep functionality together with the "main project" or other apps?
5
python,django
64,237
An 'app' could be many different things, it all really comes down to taste. For example, let's say you are building a blog. Your app could be the entire blog, or you could have an 'admin' app, a 'site' app for all of the public views, an 'rss' app, a 'services' app so developers can interface with the blog in their own ways, etc. I personally would make the blog itself the app, and break out the functionality within it. The blog could then be reused rather easily in other websites. The nice thing about Django is that it will recognize any models.py file within any level of your directory tree as a file containing Django models. So breaking your functionality out into smaller 'sub apps' within an 'app' itself won't make anything more difficult.
false
2008-09-15 16:03:22.553
35,690
1
0.024995
When to create a new app (with startapp) in Django?
130
64,464
8
I've googled around for this, but I still have trouble relating to what Django defines as "apps". Should I create a new app for each piece of functionality in a site, even though it uses models from the main project? Do you guys have good rule of thumb of when to split off a new app, and when to keep functionality together with the "main project" or other apps?
5
python,django
64,237
I prefer to think of Django applications as reusable modules or components than as "applications". This helps me encapsulate and decouple certain features from one another, improving re-usability should I decide to share a particular "app" with the community at large, and maintainability. My general approach is to bucket up specific features or feature sets into "apps" as though I were going to release them publicly. The hard part here is figuring out how big each bucket is. A good trick I use is to imagine how my apps would be used if they were released publicly. This often encourages me to shrink the buckets and more clearly define its "purpose".
false
2008-09-15 16:03:22.553
35,690
24
1
When to create a new app (with startapp) in Django?
130
68,086
8
I've googled around for this, but I still have trouble relating to what Django defines as "apps". Should I create a new app for each piece of functionality in a site, even though it uses models from the main project? Do you guys have good rule of thumb of when to split off a new app, and when to keep functionality together with the "main project" or other apps?
5
python,django
64,237
The rule I follow is it should be a new app if I want to reuse the functionality in a different project. If it needs deep understanding of the models in your project, it's probably more cohesive to stick it with the models.
false
2008-09-15 16:03:22.553
35,690
6
1
When to create a new app (with startapp) in Django?
130
64,308
8
I've googled around for this, but I still have trouble relating to what Django defines as "apps". Should I create a new app for each piece of functionality in a site, even though it uses models from the main project? Do you guys have good rule of thumb of when to split off a new app, and when to keep functionality together with the "main project" or other apps?
5
python,django
64,237
I tend to create new applications for each logically separate set of models. e.g.: User Profiles Forum Posts Blog posts
false
2008-09-15 16:03:22.553
35,690
14
1
When to create a new app (with startapp) in Django?
130
64,463,620
8
I've googled around for this, but I still have trouble relating to what Django defines as "apps". Should I create a new app for each piece of functionality in a site, even though it uses models from the main project? Do you guys have good rule of thumb of when to split off a new app, and when to keep functionality together with the "main project" or other apps?
5
python,django
64,237
The best answer to this question is given by Andrew Godwin (Django core developer): The main purpose of apps is, in my eyes, to provide logical separation of reusable components - specifically, a first-class namespace for models/admin/etc. - and to provide an easy way to turn things “on” or “off”. In some ways, it’s a relic of the time when Django was created - when Python packaging and modules were much less developed and you basically had to have your own solution to the problem. That said, it’s still a core part of Django’s mental model, and I think INSTALLED_APPS is still a cleaner, easier solution than Python’s replacement offering of entrypoints (which makes it quite hard to disable a package that is installed in an environment but which you don’t want to use). Is there anything specifically you think could be decoupled from the app concept today? Models and admin need it for autodiscovery and a unique namespace prefix, so that’s hard to undo, and I’m struggling to think of other features you need it for (in fact, if all you want is just a library, you can make it a normal Python one - no need for the app wrapping unless you’re shipping models, templates or admin code IIRC)
false
2008-09-15 16:03:22.553
35,690
2
0.049958
When to create a new app (with startapp) in Django?
130
256,833
11
I'm looking for a good server/client protocol supported in Python for making data requests/file transfers between one server and many clients. Security is also an issue - so secure login would be a plus. I've been looking into XML-RPC, but it looks to be a pretty old (and possibly unused these days?) protocol.
2
python,client
64,426
There is no need to use HTTP (indeed, HTTP is not good for RPC in general in some respects), and no need to use a standards-based protocol if you're talking about a python client talking to a python server. Use a Python-specific RPC library such as Pyro, or what Twisted provides (Twisted.spread).
false
2008-09-15 16:27:47.177
8,856
1
0.01818
Best Python supported server/client protocol?
9
256,826
11
I'm looking for a good server/client protocol supported in Python for making data requests/file transfers between one server and many clients. Security is also an issue - so secure login would be a plus. I've been looking into XML-RPC, but it looks to be a pretty old (and possibly unused these days?) protocol.
2
python,client
64,426
I suggest you look at 1. XMLRPC 2. JSONRPC 3. SOAP 4. REST/ATOM XMLRPC is a valid choice. Don't worry it is too old. That is not a problem. It is so simple that little needed changing since original specification. The pro is that in every programming langauge I know there is a library for a client to be written in. Certainly for python. I made it work with mod_python and had no problem at all. The big problem with it is its verbosity. For simple values there is a lot of XML overhead. You can gzip it of cause, but then you loose some debugging ability with the tools like Fiddler. My personal preference is JSONRPC. It has all of the XMLRPC advantages and it is very compact. Further, Javascript clients can "eval" it so no parsing is necessary. Most of them are built for version 1.0 of the standard. I have seen diverse attempts to improve on it, called 1.1 1.2 and 2.0 but they are not built one on top of another and, to my knowledge, are not widely supported yet. 2.0 looks the best, but I would still stick with 1.0 for now (October 2008) Third candidate would be REST/ATOM. REST is a principle, and ATOM is how you convey bulk of data when it needs to for POST, PUT requests and GET responses. For a very nice implementation of it, look at GData, Google's API. Real real nice. SOAP is old, and lots lots of libraries / langauges support it. IT is heeavy and complicated, but if your primary clients are .NET or Java, it might be worth the bother. Visual Studio would import your WSDL file and create a wrapper and to C# programmer it would look like local assembly indeed. The nice thing about all this, is that if you architect your solution right, existing libraries for Python would allow you support more then one with almost no overhead. XMLRPC and JSONRPC are especially good match. Regarding authentication. XMLRPC and JSONRPC don't bother defining one. It is independent thing from the serialization. So you can implement Basic Authentication, Digest Authentication or your own with any of those. I have seen couple of examples of client side Digest Authentication for python, but am yet to see the server based one. If you use Apache, you might not need one, using mod_auth_digest Apache module instead. This depens on the nature of your application Transport security. It is obvously SSL (HTTPS). I can't currently remember how XMLRPC deals with, but with JSONRPC implementation that I have it is trivial - you merely change http to https in your URLs to JSONRPC and it shall be going over SSL enabled transport.
false
2008-09-15 16:27:47.177
8,856
4
0.072599
Best Python supported server/client protocol?
9
66,818
7
I've trouble setting up Vim (7.1.xxx) for editing Python files (*.py). Indenting seems to be broken (optimal 4 spaces). I've followed some tutorials I found via Google. Still no effect :/ Please help.
1
python,vim,configuration,spaces
65,076
Ensure you are editing the correct configuration file for VIM. Especially if you are using windows, where the file could be named _vimrc instead of .vimrc as on other platforms. In vim type :help vimrc and check your path to the _vimrc/.vimrc file with :echo $HOME :echo $VIM Make sure you are only using one file. If you want to split your configuration into smaller chunks you can source other files from inside your _vimrc file. :help source
false
2008-09-15 17:48:22.817
120,959
3
0.085505
How do I set up Vim autoindentation properly for editing Python files?
89
93,027
3
My development shop has put together a fairly useful Python-based test suite, and we'd like to test some Linux-based C++ code with it. We've gotten the test project they ship with Boost to compile (type 'bjam' in the directory and it works), but we're having issues with our actual project. Building the boost libraries and bjam from source (v1.35.0), when I run bjam I get a .so in the bin/gcc-4.1.2/debug directory. I run python and "import " and I get: ImportError: libboost_python-gcc41-d-1_35.so.1.35.0: cannot open shared object file: No such file or directory Looking in the library directory, I have the following: libboost_python-gcc41-mt-1_35.so libboost_python-gcc41-mt-1_35.so.1.35.0 libboost_python-gcc41-mt.so Obviously I need the -d instead of the -mt libraries, or to point at the -mt libraries instead of -d, but I can't figure out how to make my Jamroot file do that. When I install Debian Etch's versions of the libraries, I get "No Jamfile in /usr/include" - and there's a debian bug that says they left out the system-level jamfile. I'm more hopeful about getting it working from source, so if anyone has any suggestions to resolve the library issues, I'd like to hear them. Response to answer 1: Thanks for the tip. So, do you know how I'd go about getting it to use the MT libraries instead? It appears to be more of a problem with bjam or the Jamfile I am using thinking I am in debug mode, even though I can't find any flags for that. While I know how to include specific libraries in a call to GCC, I don't see a way to configure that from the Boost end.
2
c++,boost-python
67,015
Found the solution! Boost builds a debug build by default. Typing "bjam release" builds the release configuration. (This isn't listed in any documentation anywhere, as far as I can tell.) Note that this is not the same as changing your build-type to release, as that doesn't build a release configuration. Doing a 'complete' build as Torsten suggests also does not stop it from building only a debug version. It's also worth noting that the -d libraries were in <boost-version>/bin.v2/libs/python/build/<gcc version>/debug/ and the release libraries were in <gcc-version>/release, and not installed into the top-level 'libs' directory. Thanks for the other suggestions!
false
2008-09-15 21:11:30.050
3,149
2
0.132549
Using boost-python with C++ in Linux
3
67,282
3
My development shop has put together a fairly useful Python-based test suite, and we'd like to test some Linux-based C++ code with it. We've gotten the test project they ship with Boost to compile (type 'bjam' in the directory and it works), but we're having issues with our actual project. Building the boost libraries and bjam from source (v1.35.0), when I run bjam I get a .so in the bin/gcc-4.1.2/debug directory. I run python and "import " and I get: ImportError: libboost_python-gcc41-d-1_35.so.1.35.0: cannot open shared object file: No such file or directory Looking in the library directory, I have the following: libboost_python-gcc41-mt-1_35.so libboost_python-gcc41-mt-1_35.so.1.35.0 libboost_python-gcc41-mt.so Obviously I need the -d instead of the -mt libraries, or to point at the -mt libraries instead of -d, but I can't figure out how to make my Jamroot file do that. When I install Debian Etch's versions of the libraries, I get "No Jamfile in /usr/include" - and there's a debian bug that says they left out the system-level jamfile. I'm more hopeful about getting it working from source, so if anyone has any suggestions to resolve the library issues, I'd like to hear them. Response to answer 1: Thanks for the tip. So, do you know how I'd go about getting it to use the MT libraries instead? It appears to be more of a problem with bjam or the Jamfile I am using thinking I am in debug mode, even though I can't find any flags for that. While I know how to include specific libraries in a call to GCC, I don't see a way to configure that from the Boost end.
2
c++,boost-python
67,015
If you want to build the debug variants of the boost libraries as well, you have to invoke bjam with the option --build-type=complete. On Debian, you get the debug Python interpreter in the python2.x-dbg packages. Debug builds of the Boost libraries are in libboost1.xy-dbg, if you want to use the system Boost.
false
2008-09-15 21:11:30.050
3,149
2
0.132549
Using boost-python with C++ in Linux
3
67,477
10
How to serve users a dynamically generated ZIP archive in Django? I'm making a site, where users can choose any combination of available books and download them as ZIP archive. I'm worried that generating such archives for each request would slow my server down to a crawl. I have also heard that Django doesn't currently have a good solution for serving dynamically generated files.
2
python,django
67,454
Can't you just write a link to a "zip server" or whatnot? Why does the zip archive itself need to be served from Django? A 90's era CGI script to generate a zip and spit it to stdout is really all that's required here, at least as far as I can see.
false
2008-09-15 22:00:31.540
32,479
-1
-0.019997
Serving dynamically generated ZIP archives in Django
68
73,617
10
How to serve users a dynamically generated ZIP archive in Django? I'm making a site, where users can choose any combination of available books and download them as ZIP archive. I'm worried that generating such archives for each request would slow my server down to a crawl. I have also heard that Django doesn't currently have a good solution for serving dynamically generated files.
2
python,django
67,454
I suggest to use separate model for storing those temp zip files. You can create zip on-fly, save to model with filefield and finally send url to user. Advantages: Serving static zip files with django media mechanism (like usual uploads). Ability to cleanup stale zip files by regular cron script execution (which can use date field from zip file model).
false
2008-09-15 22:00:31.540
32,479
1
0.019997
Serving dynamically generated ZIP archives in Django
68
315,462
12
I'm looking to write a programming language for fun, however most of the resource I have seen are for writing a context free language, however I wish to write a language that, like python, uses indentation, which to my understanding means it can't be context free.
5
python,compiler-construction,programming-languages,interpreter
68,243
If you're really going to take a whack at language design and implementation, you might want to add the following to your bookshelf: Programming Language Pragmatics, Scott et al. Design Concepts in Programming Languages, Turbak et al. Modern Compiler Design, Grune et al. (I sacrilegiously prefer this to "The Dragon Book" by Aho et al.) Gentler introductions such as: Crenshaw's tutorial (as suggested by @'Jonas Gorauskas' here) The Definitive ANTLR Reference by Parr Martin Fowler's recent work on DSLs You should also consider your implementation language. This is one of those areas where different languages vastly differ in what they facilitate. You should consider languages such as LISP, F# / OCaml, and Gilad Bracha's new language Newspeak.
false
2008-09-16 00:28:16.567
2,008
2
0.033321
What's a good resource for starting to write a programming language, that's not context free?
14
69,482
12
I'm looking to write a programming language for fun, however most of the resource I have seen are for writing a context free language, however I wish to write a language that, like python, uses indentation, which to my understanding means it can't be context free.
5
python,compiler-construction,programming-languages,interpreter
68,243
If you've never written a parser before, start with something simple. Parsers are surprisingly subtle, and you can get into all sorts of trouble writing them if you've never studied the structure of programming languages. Reading Aho, Sethi, and Ullman (it's known as "The Dragon Book") is a good plan. Contrary to other contributors, I say you should play with simpler parser generators like Yacc and Bison first, and only when you get burned because you can't do something with that tool should you go on to try to build something with an LL(*) parser like Antlr.
false
2008-09-16 00:28:16.567
2,008
1
0.016665
What's a good resource for starting to write a programming language, that's not context free?
14
68,575
12
I'm looking to write a programming language for fun, however most of the resource I have seen are for writing a context free language, however I wish to write a language that, like python, uses indentation, which to my understanding means it can't be context free.
5
python,compiler-construction,programming-languages,interpreter
68,243
I would recommend that you write your parser by hand, in which case having significant whitespace should not present any real problems. The main problem with using a parser generator is that it is difficult to get good error recovery in the parser. If you plan on implementing an IDE for your language, then having good error recovery is important for getting things like Intellisence to work. Intellisence always works on incomplete syntactic constructs, and the better the parser is at figuring out what construct the user is trying to type, the better an intellisence experience you can deliver. If you write a hand-written top-down parser, you can pretty much implement what ever rules you want, where ever you want to. This is what makes it easy to provide error recovery. It will also make it trivial for you to implement significant whitespace. You can simply store what the current indentation level is in a variable inside your parser class, and can stop parsing blocks when you encounter a token on a new line that has a column position that is less than the current indentation level. Also, chances are that you are going to run into ambiguities in your grammar. Most “production” languages in wide use have syntactic ambiguities. A good example is generics in C# (there are ambiguities around "<" in an expression context, it can be either a "less-than" operator, or the start of a "generic argument list"). In a hand-written parser solving ambiguities like that are trivial. You can just add a little bit of non-determinism where you need it with relatively little impact on the rest of the parser, Furthermore, because you are designing the language yourself, you should assume it's design is going to evolve rapidly (for some languages with standards committees, like C++ this is not the case). Making changes to automatically generated parsers to either handle ambiguities, or evolve the language, may require you to do significant refactoring of the grammar, which can be both irritating and time consuming. Changes to hand written parsers, particularly for top-down parsers, are usually pretty localized. I would say that parser generators are only a good choice if: You never plan on writing an IDE ever, The language has really simple syntax, or You need a parser extremely quickly, and are ok with a bad user experience
false
2008-09-16 00:28:16.567
2,008
1
0.016665
What's a good resource for starting to write a programming language, that's not context free?
14
261,520
12
I'm looking to write a programming language for fun, however most of the resource I have seen are for writing a context free language, however I wish to write a language that, like python, uses indentation, which to my understanding means it can't be context free.
5
python,compiler-construction,programming-languages,interpreter
68,243
A context-free grammar is, simply, one that doesn't require a symbol table in order to correctly parse the code. A context-sensitive grammar does. The D programming language is an example of a context free grammar. C++ is a context sensitive one. (For example, is T*x declaring x to be pointer to T, or is it multiplying T by x ? We can only tell by looking up T in the symbol table to see if it is a type or a variable.) Whitespace has nothing to do with it. D uses a context free grammar in order to greatly simplify parsing it, and so that simple tools can parse it (such as syntax highlighting editors).
false
2008-09-16 00:28:16.567
2,008
19
1
What's a good resource for starting to write a programming language, that's not context free?
14
69,185
12
I'm looking to write a programming language for fun, however most of the resource I have seen are for writing a context free language, however I wish to write a language that, like python, uses indentation, which to my understanding means it can't be context free.
5
python,compiler-construction,programming-languages,interpreter
68,243
Have you read Aho, Sethi, Ullman: "Compilers: Principles, Techniques, and Tools"? It is a classical language reference book. /Allan
false
2008-09-16 00:28:16.567
2,008
1
0.016665
What's a good resource for starting to write a programming language, that's not context free?
14
70,895
3
When trying to use libxml2 as myself I get an error saying the package cannot be found. If I run as as super user I am able to import fine. I have installed python25 and all libxml2 and libxml2-py25 related libraries via fink and own the entire path including the library. Any ideas why I'd still need to sudo?
2
python,macos,libxml2
68,541
I would suspect the permissions on the library. Can you do a strace or similar to find out the filenames it's looking for, and then check the permissions on them?
false
2008-09-16 01:27:28.110
225
0
0
libxml2-p25 on OS X 10.5 needs sudo?
0
77,114
3
When trying to use libxml2 as myself I get an error saying the package cannot be found. If I run as as super user I am able to import fine. I have installed python25 and all libxml2 and libxml2-py25 related libraries via fink and own the entire path including the library. Any ideas why I'd still need to sudo?
2
python,macos,libxml2
68,541
The PATH environment variable was the mistake.
false
2008-09-16 01:27:28.110
225
0
0
libxml2-p25 on OS X 10.5 needs sudo?
0
53,385,158
9
Is there any performance difference between tuples and lists when it comes to instantiation and retrieval of elements?
4
python,performance,list,tuples,python-internals
68,630
The main reason for Tuple to be very efficient in reading is because it's immutable. Why immutable objects are easy to read? The reason is tuples can be stored in the memory cache, unlike lists. The program always read from the lists memory location as it is mutable (can change any time).
false
2008-09-16 01:43:39.040
113,174
-6
-1
Are tuples more efficient than lists in Python?
284
70,968
9
Is there any performance difference between tuples and lists when it comes to instantiation and retrieval of elements?
4
python,performance,list,tuples,python-internals
68,630
Tuples, being immutable, are more memory efficient; lists, for speed efficiency, overallocate memory in order to allow appends without constant reallocs. So, if you want to iterate through a constant sequence of values in your code (eg for direction in 'up', 'right', 'down', 'left':), tuples are preferred, since such tuples are pre-calculated in compile time. Read-access speeds should be the same (they are both stored as contiguous arrays in the memory). But, alist.append(item) is much preferred to atuple+= (item,) when you deal with mutable data. Remember, tuples are intended to be treated as records without field names.
false
2008-09-16 01:43:39.040
113,174
41
1
Are tuples more efficient than lists in Python?
284
68,638
9
Is there any performance difference between tuples and lists when it comes to instantiation and retrieval of elements?
4
python,performance,list,tuples,python-internals
68,630
Tuples should be slightly more efficient and because of that, faster, than lists because they are immutable.
false
2008-09-16 01:43:39.040
113,174
4
0.088656
Are tuples more efficient than lists in Python?
284
71,295
9
Is there any performance difference between tuples and lists when it comes to instantiation and retrieval of elements?
4
python,performance,list,tuples,python-internals
68,630
You should also consider the array module in the standard library if all the items in your list or tuple are of the same C type. It will take less memory and can be faster.
false
2008-09-16 01:43:39.040
113,174
9
1
Are tuples more efficient than lists in Python?
284
61,080,153
26
How do I create static class variables or methods in Python?
2
python,class,oop,static,class-variables
68,645
So this is probably a hack, but I've been using eval(str) to obtain an static object, kind of a contradiction, in python 3. There is an Records.py file that has nothing but class objects defined with static methods and constructors that save some arguments. Then from another .py file I import Records but i need to dynamically select each object and then instantiate it on demand according to the type of data being read in. So where object_name = 'RecordOne' or the class name, I call cur_type = eval(object_name) and then to instantiate it you do cur_inst = cur_type(args) However before you instantiate you can call static methods from cur_type.getName() for example, kind of like abstract base class implementation or whatever the goal is. However in the backend, it's probably instantiated in python and is not truly static, because eval is returning an object....which must have been instantiated....that gives static like behavior.
false
2008-09-16 01:46:36.847
1,501,442
3
0.023073
Static class variables and methods in Python
2,352
79,840
26
How do I create static class variables or methods in Python?
2
python,class,oop,static,class-variables
68,645
To avoid any potential confusion, I would like to contrast static variables and immutable objects. Some primitive object types like integers, floats, strings, and touples are immutable in Python. This means that the object that is referred to by a given name cannot change if it is of one of the aforementioned object types. The name can be reassigned to a different object, but the object itself may not be changed. Making a variable static takes this a step further by disallowing the variable name to point to any object but that to which it currently points. (Note: this is a general software concept and not specific to Python; please see others' posts for information about implementing statics in Python).
false
2008-09-16 01:46:36.847
1,501,442
5
0.038443
Static class variables and methods in Python
2,352
70,003
6
My university doesn't support the POST cgi method (I know, it's crazy), and I was hoping to be able to have a system where a user can have a username and password and log in securely. Is this even possible? If it's not, how would you do it with POST? Just out of curiosity. Cheers!
3
python,authentication,cgi
69,979
With a bit of JavaScript, you could have the client hash the entered password and a server-generated nonce, and use that in an HTTP GET.
false
2008-09-16 07:07:42.550
2,893
0
0
Can I implement a web user authentication system in python without POST?
1
69,995
6
My university doesn't support the POST cgi method (I know, it's crazy), and I was hoping to be able to have a system where a user can have a username and password and log in securely. Is this even possible? If it's not, how would you do it with POST? Just out of curiosity. Cheers!
3
python,authentication,cgi
69,979
You can actually do it all with GET methods. However, you'll want to use a full challenge response protocol for the logins. (You can hash on the client side using javascript. You just need to send out a unique challenge each time.) You'll also want to use SSL to ensure that no one can see the strings as they go across. In some senses there's no real security difference between GET and POST requests as they both go across in plaintext, in other senses and in practice... GET is are a hell of a lot easier to intercept and is all over most people's logs and your web browser's history. :) (Or as suggested by the other posters, use a different method entirely like HTTP auth, digest auth or some higher level authentication scheme like AD, LDAP, kerberos or shib. However I kinda assumed that if you didn't have POST you wouldn't have these either.)
true
2008-09-16 07:07:42.550
2,893
5
1.2
Can I implement a web user authentication system in python without POST?
1
69,989
6
My university doesn't support the POST cgi method (I know, it's crazy), and I was hoping to be able to have a system where a user can have a username and password and log in securely. Is this even possible? If it's not, how would you do it with POST? Just out of curiosity. Cheers!
3
python,authentication,cgi
69,979
You could use HTTP Authentication, if supported. You'd have to add SSL, as all methods, POST, GET and HTTP Auth (well, except Digest HHTP authentication) send plaintext. GET is basically just like POST, it just has a limit on the amount of data you can send which is usually a lot smaller than POST and a semantic difference which makes GET not a good candidate from that point of view, even if technically they both can do it. As for examples, what are you using? There are many choices in Python, like the cgi module or some framework like Django, CherryPy, and so on
false
2008-09-16 07:07:42.550
2,893
1
0.033321
Can I implement a web user authentication system in python without POST?
1
70,869
12
How do I have a Python script that a) can accept user input and how do I make it b) read in arguments if run from the command line?
1
python,input,command-line-arguments
70,797
Careful not to use the input function, unless you know what you're doing. Unlike raw_input, input will accept any python expression, so it's kinda like eval
false
2008-09-16 09:44:59.477
1,321,249
19
1
How to prompt for user input and read command-line arguments
591
108,678
5
Does anybody know of a tool to test OCSP responses? Preferably, something that can be used from a Windows Command-line and/or can be included (easily) in a Java/python program
1
java,python,command-line,ocsp
71,468
bouncycastle has a Java crypto-provider and support for OCSP requests and responses. The differences between OCSPReq and OCSPRequest and OCSPResp and OCSPResponse class are a little confusing, though.
false
2008-09-16 11:44:28.643
8,106
1
0.039979
OCSP command-line test tool?
3
73,473
5
The problem: I have a class which contains a template method execute which calls another method _execute. Subclasses are supposed to overwrite _execute to implement some specific functionality. This functionality should be documented in the docstring of _execute. Advanced users can create their own subclasses to extend the library. However, another user dealing with such a subclass should only use execute, so he won't see the correct docstring if he uses help(execute). Therefore it would be nice to modify the base class in such a way that in a subclass the docstring of execute is automatically replaced with that of _execute. Any ideas how this might be done? I was thinking of metaclasses to do this, to make this completely transparent to the user.
2
python,metaclass
71,817
Look at the functools.wraps() decorator; it does all of this, but I don't know offhand if you can get it to run in the right context
false
2008-09-16 12:46:28.150
2,897
1
0.039979
Using the docstring from one method to automatically overwrite that of another method
4
72,126
5
The problem: I have a class which contains a template method execute which calls another method _execute. Subclasses are supposed to overwrite _execute to implement some specific functionality. This functionality should be documented in the docstring of _execute. Advanced users can create their own subclasses to extend the library. However, another user dealing with such a subclass should only use execute, so he won't see the correct docstring if he uses help(execute). Therefore it would be nice to modify the base class in such a way that in a subclass the docstring of execute is automatically replaced with that of _execute. Any ideas how this might be done? I was thinking of metaclasses to do this, to make this completely transparent to the user.
2
python,metaclass
71,817
Well the doc-string is stored in __doc__ so it wouldn't be too hard to re-assign it based on the doc-string of _execute after the fact. Basically: class MyClass(object): def execute(self): '''original doc-string''' self._execute() class SubClass(MyClass): def _execute(self): '''sub-class doc-string''' pass # re-assign doc-string of execute def execute(self,*args,**kw): return MyClass.execute(*args,**kw) execute.__doc__=_execute.__doc__ Execute has to be re-declared to that the doc string gets attached to the version of execute for the SubClass and not for MyClass (which would otherwise interfere with other sub-classes). That's not a very tidy way of doing it, but from the POV of the user of a library it should give the desired result. You could then wrap this up in a meta-class to make it easier for people who are sub-classing.
false
2008-09-16 12:46:28.150
2,897
0
0
Using the docstring from one method to automatically overwrite that of another method
4
70,824,754
12
I am aware of the die() command in PHP which exits a script early. How can I do this in Python?
2
python,termination
73,663
Just put at the end of your code quit() and that should close a python script.
false
2008-09-16 15:35:55.637
1,876,007
0
0
How to terminate a script?
1,288
76,374
12
I am aware of the die() command in PHP which exits a script early. How can I do this in Python?
2
python,termination
73,663
While you should generally prefer sys.exit because it is more "friendly" to other code, all it actually does is raise an exception. If you are sure that you need to exit a process immediately, and you might be inside of some exception handler which would catch SystemExit, there is another function - os._exit - which terminates immediately at the C level and does not perform any of the normal tear-down of the interpreter; for example, hooks registered with the "atexit" module are not executed.
false
2008-09-16 15:35:55.637
1,876,007
75
1
How to terminate a script?
1,288
934,717
6
Is it possible to call managed code, specifically IronRuby or IronPython from unamanaged code such as C++ or Delphi? For example, we have an application written in Delphi that is being moved to C#.NET We'd like to provide Ruby or Python scripting in our new application to replace VBSCRIPT. However, we would need to provide Ruby/Python scripting in the old Delphi application. Is it possible to use the managed dlls provided by IronRuby/IronPython from Delphi code?
1
.net,delphi,ironpython,unmanaged,ironruby
74,386
Why not embed CPython instead, which has an API intended to be used directly from C/C++. You lose the multiple language advantage but probably gain simplicity.
false
2008-09-16 16:44:27.547
877
3
0.099668
Using DLR from Unmanaged Code
5
76,404
8
I am trying to use the import random statement in python, but it doesn't appear to have any methods in it to use. Am I missing something?
2
python
74,430
If the script you are trying to run is itself called random.py, then you would have a naming conflict. Choose a different name for your script.
false
2008-09-16 16:49:33.963
5,445
1
0.024995
Random in python 2.5 not working?
9
78,304
8
I am trying to use the import random statement in python, but it doesn't appear to have any methods in it to use. Am I missing something?
2
python
74,430
This is happening because you have a random.py file in the python search path, most likely the current directory. Python is searching for modules using sys.path, which normally includes the current directory before the standard site-packages, which contains the expected random.py. This is expected to be fixed in Python 3.0, so that you can't import modules from the current directory without using a special import syntax. Just remove the random.py + random.pyc in the directory you're running python from and it'll work fine.
false
2008-09-16 16:49:33.963
5,445
3
0.07486
Random in python 2.5 not working?
9
75,456
5
What method do I call to get the name of a class?
2
python
75,440
It's not a method, it's a field. The field is called __name__. class.__name__ will give the name of the class as a string. object.__class__.__name__ will give the name of the class of an object.
false
2008-09-16 18:26:47.427
45,412
43
1
How do I get the string with name of a class?
50
77,222
5
What method do I call to get the name of a class?
2
python
75,440
In [8]: str('2'.__class__) Out[8]: "<type 'str'>" In [9]: str(len.__class__) Out[9]: "<type 'builtin_function_or_method'>" In [10]: str(4.6.__class__) Out[10]: "<type 'float'>" Or, as was pointed out before, In [11]: 4.6.__class__.__name__ Out[11]: 'float'
false
2008-09-16 18:26:47.427
45,412
1
0.039979
How do I get the string with name of a class?
50
1,997,668
9
I'm wondering if there's such a thing as Django-like ease of web app development combined with good deployment, debugging and other tools? Django is a very productive framework for building content-heavy sites; the best I've tried and a breath of fresh air compared to some of the Java monstrosities out there. However it's written in Python which means there's little real support in the way of deployment/packaging, debugging, profilers and other tools that make building and maintaining applications much easier. Ruby has similar issues and although I do like Ruby much better than I like Python, I get the impression that Rails is roughly in the same boat at Django when it comes to managing/supporting the app. Has anyone here tried both Django and Grails (or other web frameworks) for non-trivial projects? How did they compare?
5
python,django,frameworks
75,798
The statement that grails deletes the database on start-up is completely wrong. It's behavior on start-up is completely configurable and easy to configure. I generally use create-drop when running an app in dev mode. I use update when I run in test and production. I also love the bootstrap processing that lets me pre-configure test users, data, etc by environment in Grails. I'd love to see someone who has really built and deployed some commercial projects comment on the pros / cons. Be a really interesting read.
false
2008-09-16 19:05:48.660
19,797
10
1
Django -vs- Grails -vs-?
23
460,360
9
I'm wondering if there's such a thing as Django-like ease of web app development combined with good deployment, debugging and other tools? Django is a very productive framework for building content-heavy sites; the best I've tried and a breath of fresh air compared to some of the Java monstrosities out there. However it's written in Python which means there's little real support in the way of deployment/packaging, debugging, profilers and other tools that make building and maintaining applications much easier. Ruby has similar issues and although I do like Ruby much better than I like Python, I get the impression that Rails is roughly in the same boat at Django when it comes to managing/supporting the app. Has anyone here tried both Django and Grails (or other web frameworks) for non-trivial projects? How did they compare?
5
python,django,frameworks
75,798
Grails. Grails just looks like Rails (Ruby),but it uses groovy which is simpler than java. It uses java technology and you can use any java lib without any trouble. I also choose Grails over simplicity and there are lots of java lib (such as jasper report, jawr etc) and I am glad that now they join with SpringSource which makes their base solid.
false
2008-09-16 19:05:48.660
19,797
10
1
Django -vs- Grails -vs-?
23
81,699
9
I'm wondering if there's such a thing as Django-like ease of web app development combined with good deployment, debugging and other tools? Django is a very productive framework for building content-heavy sites; the best I've tried and a breath of fresh air compared to some of the Java monstrosities out there. However it's written in Python which means there's little real support in the way of deployment/packaging, debugging, profilers and other tools that make building and maintaining applications much easier. Ruby has similar issues and although I do like Ruby much better than I like Python, I get the impression that Rails is roughly in the same boat at Django when it comes to managing/supporting the app. Has anyone here tried both Django and Grails (or other web frameworks) for non-trivial projects? How did they compare?
5
python,django,frameworks
75,798
Personally I made some rather big projects with Django, but I can compare only with said "montrosities" (Spring, EJB) and really low-level stuff like Twisted. Web frameworks using interpreted languages are mostly in its infancy and all of them (actively maintained, that is) are getting better with every day.
false
2008-09-16 19:05:48.660
19,797
1
0.022219
Django -vs- Grails -vs-?
23
76,198
9
I'm wondering if there's such a thing as Django-like ease of web app development combined with good deployment, debugging and other tools? Django is a very productive framework for building content-heavy sites; the best I've tried and a breath of fresh air compared to some of the Java monstrosities out there. However it's written in Python which means there's little real support in the way of deployment/packaging, debugging, profilers and other tools that make building and maintaining applications much easier. Ruby has similar issues and although I do like Ruby much better than I like Python, I get the impression that Rails is roughly in the same boat at Django when it comes to managing/supporting the app. Has anyone here tried both Django and Grails (or other web frameworks) for non-trivial projects? How did they compare?
5
python,django,frameworks
75,798
cakephp.org Cakephp is really good, really close to ruby on rails (1.2). It is in php, works very well on shared hosts and is easy to implement. The only downside is that the documentation is somewhat lacking, but you quickly get it and quickly start doing cool stuff. I totally recommend cakephp.
false
2008-09-16 19:05:48.660
19,797
1
0.022219
Django -vs- Grails -vs-?
23
1,955,727
9
I'm wondering if there's such a thing as Django-like ease of web app development combined with good deployment, debugging and other tools? Django is a very productive framework for building content-heavy sites; the best I've tried and a breath of fresh air compared to some of the Java monstrosities out there. However it's written in Python which means there's little real support in the way of deployment/packaging, debugging, profilers and other tools that make building and maintaining applications much easier. Ruby has similar issues and although I do like Ruby much better than I like Python, I get the impression that Rails is roughly in the same boat at Django when it comes to managing/supporting the app. Has anyone here tried both Django and Grails (or other web frameworks) for non-trivial projects? How did they compare?
5
python,django,frameworks
75,798
You asked for someone who used both Grails and Django. I've done work on both for big projects. Here's my Thoughts: IDE's: Django works really well in Eclipse, Grails works really well in IntelliJ Idea. Debugging: Practically the same (assuming you use IntelliJ for Grails, and Eclipse for Python). Step debugging, inspecting variables, etc... never need a print statement for either. Sometimes django error messages can be useless but Grails error messages are usually pretty lengthy and hard to parse through. Time to run a unit test: django: 2 seconds. Grails: 20 seconds (the tests themselves both run in a fraction of a second, it's the part about loading the framework to run them that takes the rest... as you can see, Grails is frustratingly slow to load). Deployment: Django: copy & paste one file into an apache config, and to redeploy, just change the code and reload apache. Grails: create a .war file, deploy it on tomcat, rinse and repeat to redeploy. Programming languages: Groovy is TOTALLY awesome. I love it, more so than Python. But I certainly have no complaints. Plugins: Grails: lots of broken plugins (and can use every java lib ever). Django: a few stable plugins, but enough to do most of what you need. Database: Django: schema migrations using South, and generally intuitive relations. Grails: no schema migrations, and by default it deletes the database on startup... WTF Usage: Django: startups (especially in the Gov 2.0 space), independent web dev shops. Grails: enterprise Hope that helps!
true
2008-09-16 19:05:48.660
19,797
32
1.2
Django -vs- Grails -vs-?
23
315,406
3
All the docs for SQLAlchemy give INSERT and UPDATE examples using the local table instance (e.g. tablename.update()... ) Doing this seems difficult with the declarative syntax, I need to reference Base.metadata.tables["tablename"] to get the table reference. Am I supposed to do this another way? Is there a different syntax for INSERT and UPDATE recommended when using the declarative syntax? Should I just switch to the old way?
2
python,sql,sqlalchemy
75,829
There may be some confusion between table (the object) and tablename (the name of the table, a string). Using the table class attribute works fine for me.
false
2008-09-16 19:08:29.683
2,919
0
0
Best way to access table instances when using SQLAlchemy's declarative syntax
8
77,962
3
All the docs for SQLAlchemy give INSERT and UPDATE examples using the local table instance (e.g. tablename.update()... ) Doing this seems difficult with the declarative syntax, I need to reference Base.metadata.tables["tablename"] to get the table reference. Am I supposed to do this another way? Is there a different syntax for INSERT and UPDATE recommended when using the declarative syntax? Should I just switch to the old way?
2
python,sql,sqlalchemy
75,829
via the __table__ attribute on your declarative class
false
2008-09-16 19:08:29.683
2,919
4
0.26052
Best way to access table instances when using SQLAlchemy's declarative syntax
8
76,470
12
First of all, I want to avoid a flame-war on languages. The languages to choose from are Perl, Python and Ruby . I want to mention that I'm comfortable with all of them, but the problem is that I can't focus just on one. If, for example, I see a cool Perl module, I have to try it out. If I see a nice Python app, I have to know how it's made. If I see a Ruby DSL or some Ruby voodoo, I'm hooked on Ruby for a while. Right now I'm working as a Java developer, but plan on taking CEH in the near future. My question is: for tool writing and exploit development, which language do you find to be the most appropriate? Again, I don't want to cause a flame-war or any trouble, I just want honest opinions from scripters that know what they're doing. One more thing: maybe some of you will ask "Why settle on one language?". To answer this: I would like to choose only one language, in order to try to master it.
7
python,ruby,perl,security,penetration-testing
76,408
Well, what kind of exploits are you thinking about? If you want to write something that needs low level stuff (ptrace, raw sockets, etc.) then you'll need to learn C. But both Perl and Python can be used. The real question is which one suits your style more? As for toolmaking, Perl has good string-processing abilities, is closer to the system, has good support, but IMHO it's very confusing. I prefer Python: it's a clean, easy to use, easy to learn language with good support (complete language/lib reference, 3rd party libs, etc.). And it's (strictly IMHO) cool.
false
2008-09-16 20:11:22.217
6,338
0
0
Which of these scripting languages is more appropriate for pen-testing?
6
76,508
12
First of all, I want to avoid a flame-war on languages. The languages to choose from are Perl, Python and Ruby . I want to mention that I'm comfortable with all of them, but the problem is that I can't focus just on one. If, for example, I see a cool Perl module, I have to try it out. If I see a nice Python app, I have to know how it's made. If I see a Ruby DSL or some Ruby voodoo, I'm hooked on Ruby for a while. Right now I'm working as a Java developer, but plan on taking CEH in the near future. My question is: for tool writing and exploit development, which language do you find to be the most appropriate? Again, I don't want to cause a flame-war or any trouble, I just want honest opinions from scripters that know what they're doing. One more thing: maybe some of you will ask "Why settle on one language?". To answer this: I would like to choose only one language, in order to try to master it.
7
python,ruby,perl,security,penetration-testing
76,408
If you're looking for a scripting language that will play well with Java, you might want to look at Groovy. It has the flexibility and power of Perl (closures, built in regexes, associative arrays on every corner) but you can access Java code from it thus you have access to a huge number of libraries, and in particular the rest of the system you're developing.
false
2008-09-16 20:11:22.217
6,338
1
0.016665
Which of these scripting languages is more appropriate for pen-testing?
6
76,495
12
First of all, I want to avoid a flame-war on languages. The languages to choose from are Perl, Python and Ruby . I want to mention that I'm comfortable with all of them, but the problem is that I can't focus just on one. If, for example, I see a cool Perl module, I have to try it out. If I see a nice Python app, I have to know how it's made. If I see a Ruby DSL or some Ruby voodoo, I'm hooked on Ruby for a while. Right now I'm working as a Java developer, but plan on taking CEH in the near future. My question is: for tool writing and exploit development, which language do you find to be the most appropriate? Again, I don't want to cause a flame-war or any trouble, I just want honest opinions from scripters that know what they're doing. One more thing: maybe some of you will ask "Why settle on one language?". To answer this: I would like to choose only one language, in order to try to master it.
7
python,ruby,perl,security,penetration-testing
76,408
All of them should be sufficient for that. Unless you need some library that is only available in one language, I'd let personal preference guide me.
false
2008-09-16 20:11:22.217
6,338
1
0.016665
Which of these scripting languages is more appropriate for pen-testing?
6
4,927,367
12
First of all, I want to avoid a flame-war on languages. The languages to choose from are Perl, Python and Ruby . I want to mention that I'm comfortable with all of them, but the problem is that I can't focus just on one. If, for example, I see a cool Perl module, I have to try it out. If I see a nice Python app, I have to know how it's made. If I see a Ruby DSL or some Ruby voodoo, I'm hooked on Ruby for a while. Right now I'm working as a Java developer, but plan on taking CEH in the near future. My question is: for tool writing and exploit development, which language do you find to be the most appropriate? Again, I don't want to cause a flame-war or any trouble, I just want honest opinions from scripters that know what they're doing. One more thing: maybe some of you will ask "Why settle on one language?". To answer this: I would like to choose only one language, in order to try to master it.
7
python,ruby,perl,security,penetration-testing
76,408
I'm with tqbf. I've worked with Python and Ruby. Currently I'm working with JRuby. It has all the power of Ruby with access to the Java libraries so if there is something you absolutely need a low-level language to solve you can do so with a high-level language. So far I haven't needed to really use much Java as Ruby has had the ability to do everything I've needed as an API tester.
false
2008-09-16 20:11:22.217
6,338
0
0
Which of these scripting languages is more appropriate for pen-testing?
6
78,106
12
First of all, I want to avoid a flame-war on languages. The languages to choose from are Perl, Python and Ruby . I want to mention that I'm comfortable with all of them, but the problem is that I can't focus just on one. If, for example, I see a cool Perl module, I have to try it out. If I see a nice Python app, I have to know how it's made. If I see a Ruby DSL or some Ruby voodoo, I'm hooked on Ruby for a while. Right now I'm working as a Java developer, but plan on taking CEH in the near future. My question is: for tool writing and exploit development, which language do you find to be the most appropriate? Again, I don't want to cause a flame-war or any trouble, I just want honest opinions from scripters that know what they're doing. One more thing: maybe some of you will ask "Why settle on one language?". To answer this: I would like to choose only one language, in order to try to master it.
7
python,ruby,perl,security,penetration-testing
76,408
If you plan on using Metasploit for pen-testing and exploit development I would recommend ruby as mentioned previously Metasploit is written in ruby and any exploit/module development you may wish to do will require ruby. If you will be using Immunity CANVAS for pen testing then for the same reasons I would recommend Python as CANVAS is written in python. Also allot of fuzzing frameworks like Peach and Sulley are written in Python. I would not recommend Perl as you will find very little tools/scripts/frameworks related to pen testing/fuzzing/exploits/... in Perl. As your question is "tool writing and exploit development" I would recommend Ruby if you choose Metasploit or python if you choose CANVAS. hope that helps :)
false
2008-09-16 20:11:22.217
6,338
3
0.049958
Which of these scripting languages is more appropriate for pen-testing?
6
77,717
12
First of all, I want to avoid a flame-war on languages. The languages to choose from are Perl, Python and Ruby . I want to mention that I'm comfortable with all of them, but the problem is that I can't focus just on one. If, for example, I see a cool Perl module, I have to try it out. If I see a nice Python app, I have to know how it's made. If I see a Ruby DSL or some Ruby voodoo, I'm hooked on Ruby for a while. Right now I'm working as a Java developer, but plan on taking CEH in the near future. My question is: for tool writing and exploit development, which language do you find to be the most appropriate? Again, I don't want to cause a flame-war or any trouble, I just want honest opinions from scripters that know what they're doing. One more thing: maybe some of you will ask "Why settle on one language?". To answer this: I would like to choose only one language, in order to try to master it.
7
python,ruby,perl,security,penetration-testing
76,408
[Disclaimer: I am primarily a Perl programmer, which may be colouring my judgement. However, I am not a particularly tribal one, and I think on this particular question my argument is reasonably objective.] Perl was designed to blend seamlessly into the Unix landscape, and that is why it feels so alien to people with a mainly-OO background (particularly the Java school of OOP). For that reason, though, it’s incredibly widely installed on machines with any kind of Unixoid OS, and many vendor system utilities are written in it. Also for the same reason, servers that have neither Python nor Ruby installed are still likely to have Perl on them, again making it important to have some familiarity with. So if your CEH activity includes extensive activity on Unix, you will have to have some amount of familiarity with Perl anyway, and you might as well focus on it. That said, it is largely a matter of preference. There is not much to differentiate the languages; their expressive power is virtually identical. Some things are a little easier in one of the languages, some a little easier in another. In terms of libraries I do not know how Ruby and Python compare against each other – I do know that Perl has them beat by a margin. Then again, sometimes (particularly when you’re looking for libraries for common needs) the only effect of that is that you get deluged with choices. And if you are only looking to do things in some particular area which is well covered by libraries for Python or Ruby, the mass of other stuff on CPAN isn’t necessarily an advantage. In niche areas, however, it matters, and you never know what unforeseen need you will eventually have (err, by definition). For one-liner use on the command line, Python is kind of a non-starter. In terms of interactive interpreter environment, Perl… uhm… well, you can use the debugger, which is not that great, or you can install one from CPAN, but Perl doesn’t ship a good one itself. So I think Perl does have a very slight edge for your needs in particular, but only just. If you pick Ruby you’ll probably not be much worse off at all. Python might inconvenience you a little more noticeably, but it too is hardly a bad choice.
false
2008-09-16 20:11:22.217
6,338
8
1
Which of these scripting languages is more appropriate for pen-testing?
6
76,441
12
First of all, I want to avoid a flame-war on languages. The languages to choose from are Perl, Python and Ruby . I want to mention that I'm comfortable with all of them, but the problem is that I can't focus just on one. If, for example, I see a cool Perl module, I have to try it out. If I see a nice Python app, I have to know how it's made. If I see a Ruby DSL or some Ruby voodoo, I'm hooked on Ruby for a while. Right now I'm working as a Java developer, but plan on taking CEH in the near future. My question is: for tool writing and exploit development, which language do you find to be the most appropriate? Again, I don't want to cause a flame-war or any trouble, I just want honest opinions from scripters that know what they're doing. One more thing: maybe some of you will ask "Why settle on one language?". To answer this: I would like to choose only one language, in order to try to master it.
7
python,ruby,perl,security,penetration-testing
76,408
That depends on the implementation, if it will be distributed I would go with Java, seeing as you know that, because of its portability. If it is just for internal use, or will be used in semi-controlled environments, then go with whatever you are the most comfortable maintaining, and whichever has the best long-term outlook. Now to just answer the question, I would go with Perl, but I'm a linux guy so I may be a bit biased in this.
false
2008-09-16 20:11:22.217
6,338
3
0.049958
Which of these scripting languages is more appropriate for pen-testing?
6
189,311
8
I have written a lot of code in Python, and I am very used to the syntax, object structure, and so forth of Python because of it. What is the best online guide or resource site to provide me with the basics, as well as a comparison or lookup guide with equivalent functions/features in VBA versus Python. For example, I am having trouble equating a simple List in Python to VBA code. I am also have issues with data structures, such as dictionaries, and so forth. What resources or tutorials are available that will provide me with a guide to porting python functionality to VBA, or just adapting to the VBA syntax from a strong OOP language background?
3
python,vba,porting
76,882
While I'm not a Python programmer, you might be able to run VSTO with Iron Python and Visual Studio. At least that way, you won't have to learn VBA syntax.
false
2008-09-16 20:48:05.950
9,282
2
0.049958
Resources for Python Programmer
21
76,989
8
I have written a lot of code in Python, and I am very used to the syntax, object structure, and so forth of Python because of it. What is the best online guide or resource site to provide me with the basics, as well as a comparison or lookup guide with equivalent functions/features in VBA versus Python. For example, I am having trouble equating a simple List in Python to VBA code. I am also have issues with data structures, such as dictionaries, and so forth. What resources or tutorials are available that will provide me with a guide to porting python functionality to VBA, or just adapting to the VBA syntax from a strong OOP language background?
3
python,vba,porting
76,882
VBA as in what was implemented as part of Office 2000, 2003 and VB6 have been deprecated in favor of .Net technologies. Unless you are maintaining old code stick to python or maybe even go with IronPython for .Net. If you go IronPython, you may have to write some C#/VB.Net helper classes here and there when working with various COM objects such as ones in Office but otherwise it is supposed to be pretty functional and nice. Just about all of the Python goodness is over in IronPython. If you are just doing some COM scripting take a look at what ActiveState puts out. I've used it in the past to do some COM work. Specifically using Python as an Active Scripting language (classic ASP).
false
2008-09-16 20:48:05.950
9,282
2
0.049958
Resources for Python Programmer
21
186,583
8
I have written a lot of code in Python, and I am very used to the syntax, object structure, and so forth of Python because of it. What is the best online guide or resource site to provide me with the basics, as well as a comparison or lookup guide with equivalent functions/features in VBA versus Python. For example, I am having trouble equating a simple List in Python to VBA code. I am also have issues with data structures, such as dictionaries, and so forth. What resources or tutorials are available that will provide me with a guide to porting python functionality to VBA, or just adapting to the VBA syntax from a strong OOP language background?
3
python,vba,porting
76,882
VBA is quite different from Python, so you should read at least the "Microsoft Visual Basic Help" as provided by the application you are going to use (Excel, Access…). Generally speaking, VBA has the equivalent of Python modules; they're called "Libraries", and they are not as easy to create as Python modules. I mention them because Libraries will provide you with higher-level types that you can use. As a start-up nudge, there are two types that can be substituted for list and dict. list VBA has the type Collection. It's available by default (it's in the library VBA). So you just do a dim alist as New Collection and from then on, you can use its methods/properties: .Add(item) ( list.append(item) ), .Count ( len(list) ), .Item(i) ( list[i] ) and .Remove(i) ( del list[i] ). Very primitive, but it's there. You can also use the VBA Array type, which like python arrays are lists of same-type items, and unlike python arrays, you need to do ReDim to change their size (i.e. you can't just append and remove items) dict To have a dictionary-like object, you should add the Scripting library to your VBA project¹. Afterwards, you can Dim adict As New Dictionary and then use its properties/methods: .Add(key, item) ( dict[key] = item ), .Exists(key) ( dict.has_key[key] ), .Items() ( dict.values() ), .Keys() ( dict.keys() ), and others which you will find in the Object Browser². ¹ Open VBA editor (Alt+F11). Go to Tools→References, and check the "Microsoft Scripting Runtime" in the list. ² To see the Object Browser, in VBA editor press F2 (or View→Object Browser).
false
2008-09-16 20:48:05.950
9,282
25
1
Resources for Python Programmer
21
33,627,050
10
Which is faster, python webpages or php webpages? Does anyone know how the speed of pylons(or any of the other frameworks) compares to a similar website made with php? I know that serving a python base webpage via cgi is slower than php because of its long start up every time. I enjoy using pylons and I would still use it if it was slower than php. But if pylons was faster than php, I could maybe, hopefully, eventually convince my employer to allow me to convert the site over to pylons.
9
php,python,performance,pylons
77,086
I would assume that PHP (>5.5) is faster and more reliable for complex web applications because it is optimized for website scripting. Many of the benchmarks you will find at the net are only made to prove that the favoured language is better. But you can not compare 2 languages with a mathematical task running X-times. For a real benchmark you need two comparable frameworks with hundreds of classes/files an a web application running 100 clients at once.
false
2008-09-16 21:05:26.673
58,657
7
1
Which is faster, python webpages or php webpages?
41
2,412,215
10
Which is faster, python webpages or php webpages? Does anyone know how the speed of pylons(or any of the other frameworks) compares to a similar website made with php? I know that serving a python base webpage via cgi is slower than php because of its long start up every time. I enjoy using pylons and I would still use it if it was slower than php. But if pylons was faster than php, I could maybe, hopefully, eventually convince my employer to allow me to convert the site over to pylons.
9
php,python,performance,pylons
77,086
I had to come back to web development at my new job, and, if not Pylons/Python, maybe I would have chosen to live in jungle instead :) In my subjective opinion, PHP is for kindergarten, I did it in my 3rd year of uni and, I believe, many self-respecting (or over-estimating) software engineers will not want to be bothered with PHP code. Why my employers agreed? We (the team) just switched to Python, and they did not have much to say. The website still is and will be PHP, but we are developing other applications, including web, in Python. Advantages of Pylons? You can integrate your python libraries into the web app, and that is, imho, a huge advantage. As for performance, we are still having troubles.
false
2008-09-16 21:05:26.673
58,657
-1
-0.019997
Which is faster, python webpages or php webpages?
41