CreationDate
stringlengths
23
23
Users Score
int64
-42
1.15k
Tags
stringlengths
6
105
AnswerCount
int64
1
64
A_Id
int64
518
76.4M
Title
stringlengths
11
150
Q_Id
int64
337
73M
is_accepted
bool
2 classes
ViewCount
int64
7
6.81M
Question
stringlengths
15
29.1k
Score
float64
-1
1.2
Q_Score
int64
0
6.79k
Available Count
int64
1
31
Answer
stringlengths
6
11.6k
2008-09-11T08:18:00.000
2
python,coding-style
19
104,842
Single quotes vs. double quotes in Python
56,011
false
712,544
According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other?
0.02105
718
12
It's probably a stylistic preference more than anything. I just checked PEP 8 and didn't see any mention of single versus double quotes. I prefer single quotes because its only one keystroke instead of two. That is, I don't have to mash the shift key to make single quote.
2008-09-11T08:18:00.000
2
python,coding-style
19
3,179,568
Single quotes vs. double quotes in Python
56,011
false
712,544
According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other?
0.02105
718
12
In Perl you want to use single quotes when you have a string which doesn't need to interpolate variables or escaped characters like \n, \t, \r, etc. PHP makes the same distinction as Perl: content in single quotes will not be interpreted (not even \n will be converted), as opposed to double quotes which can contain variables to have their value printed out. Python does not, I'm afraid. Technically seen, there is no $ token (or the like) to separate a name/text from a variable in Python. Both features make Python more readable, less confusing, after all. Single and double quotes can be used interchangeably in Python.
2008-09-11T12:29:00.000
2
python,erp,dabo
2
103,212
Anyone used Dabo for a medium-big project?
56,417
false
4,033
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!
0.197375
21
1
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
2008-09-12T04:21:00.000
9
python,sockets
9
58,296
How do I get the external IP of a socket in Python?
58,294
true
19,360
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?
1.2
10
2
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.
2008-09-12T04:21:00.000
2
python,sockets
9
256,358
How do I get the external IP of a socket in Python?
58,294
false
19,360
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?
0.044415
10
2
import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("msn.com",80)) s.getsockname()
2008-09-12T23:28:00.000
0
python,linux,firefox,ubuntu,automation
8
60,218
Automate firefox with python?
60,152
false
21,896
Been scouring the net for something like firewatir but for python. I'm trying to automate firefox on linux. Any suggestions?
0
12
2
The languages of choice of Firefox is Javascript. Unless you have a specific requirement that requires Python, I would advice you to use that.
2008-09-12T23:28:00.000
1
python,linux,firefox,ubuntu,automation
8
7,610,441
Automate firefox with python?
60,152
false
21,896
Been scouring the net for something like firewatir but for python. I'm trying to automate firefox on linux. Any suggestions?
0.024995
12
2
I would suggest you to use Selenium instead of Mechanize/Twill because Mechanize would fail while handling Javascript.
2008-09-13T05:51:00.000
7
python,version-control,distutils
2
60,431
Can distutils create empty __init__.py files?
60,352
false
1,565
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
0
1
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 ?
2008-09-13T09:56:00.000
9
python,windows-mobile
4
60,945
Windows Mobile development in Python
60,446
false
7,815
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
4
1
(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.
2008-09-13T20:38:00.000
0
python,dictionary
11
103,211
How do you retrieve items from a dictionary in the order that they're inserted?
60,848
false
47,709
Is it possible to retrieve items from a Python dictionary in the order that they were inserted?
0
65
4
It's not possible unless you store the keys in a separate list for referencing later.
2008-09-13T20:38:00.000
5
python,dictionary
11
65,991
How do you retrieve items from a dictionary in the order that they're inserted?
60,848
false
47,709
Is it possible to retrieve items from a Python dictionary in the order that they were inserted?
0.090659
65
4
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
2008-09-13T20:38:00.000
5
python,dictionary
11
60,852
How do you retrieve items from a dictionary in the order that they're inserted?
60,848
false
47,709
Is it possible to retrieve items from a Python dictionary in the order that they were inserted?
0.090659
65
4
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.
2008-09-13T20:38:00.000
-1
python,dictionary
11
64,266
How do you retrieve items from a dictionary in the order that they're inserted?
60,848
false
47,709
Is it possible to retrieve items from a Python dictionary in the order that they were inserted?
-0.01818
65
4
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?
2008-09-14T05:41:00.000
1
python,unit-testing,code-organization
18
61,820
Where do the Python unit tests go?
61,151
false
112,049
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?
0.011111
545
4
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.
2008-09-14T05:41:00.000
0
python,unit-testing,code-organization
18
63,645
Where do the Python unit tests go?
61,151
false
112,049
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?
0
545
4
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.
2008-09-14T05:41:00.000
-2
python,unit-testing,code-organization
18
61,518
Where do the Python unit tests go?
61,151
false
112,049
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?
-0.022219
545
4
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.
2008-09-14T05:41:00.000
13
python,unit-testing,code-organization
18
61,168
Where do the Python unit tests go?
61,151
false
112,049
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?
1
545
4
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.
2008-09-14T18:58:00.000
1
spell-checking,mod-python,aspell
1
61,570
Spell Checking Service with python using mod_python
61,556
false
238
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?
0.197375
0
1
Looks like RHEL4 is the culprit. Works well on Fedore 7 (the version of apache is newer and there is no crash)
2008-09-15T12:57:00.000
0
python,string,case-insensitive
16
62,592
Ignore case in Python strings
62,567
false
109,190
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).
0
52
4
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.
2008-09-15T12:57:00.000
-1
python,string,case-insensitive
16
62,652
Ignore case in Python strings
62,567
false
109,190
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).
-0.012499
52
4
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.
2008-09-15T12:57:00.000
0
python,string,case-insensitive
16
62,983
Ignore case in Python strings
62,567
false
109,190
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).
0
52
4
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.
2008-09-15T12:57:00.000
0
python,string,case-insensitive
16
65,834
Ignore case in Python strings
62,567
false
109,190
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).
0
52
4
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.
2008-09-15T13:55:00.000
1
python
22
1,538,995
Is there a way around coding in Python without the tab, indent & whitespace criteria?
63,086
false
15,517
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?
0.009091
10
16
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.
2008-09-15T13:55:00.000
0
python
22
64,186
Is there a way around coding in Python without the tab, indent & whitespace criteria?
63,086
false
15,517
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?
0
10
16
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.
2008-09-15T13:55:00.000
0
python
22
64,899
Is there a way around coding in Python without the tab, indent & whitespace criteria?
63,086
false
15,517
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?
0
10
16
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.
2008-09-15T13:55:00.000
0
python
22
69,064
Is there a way around coding in Python without the tab, indent & whitespace criteria?
63,086
false
15,517
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?
0
10
16
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.
2008-09-15T13:55:00.000
1
python
22
63,450
Is there a way around coding in Python without the tab, indent & whitespace criteria?
63,086
false
15,517
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?
0.009091
10
16
I was a bit reluctant to learn Python because of tabbing. However, I almost didn't notice it when I used Vim.
2008-09-15T13:55:00.000
2
python
22
63,289
Is there a way around coding in Python without the tab, indent & whitespace criteria?
63,086
false
15,517
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?
0.01818
10
16
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.
2008-09-15T13:55:00.000
0
python
22
1,515,244
Is there a way around coding in Python without the tab, indent & whitespace criteria?
63,086
false
15,517
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?
0
10
16
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.
2008-09-15T13:55:00.000
37
python
22
63,094
Is there a way around coding in Python without the tab, indent & whitespace criteria?
63,086
false
15,517
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?
1
10
16
No. Indentation-as-grammar is an integral part of the Python language, for better and worse.
2008-09-15T13:55:00.000
3
python
22
63,122
Is there a way around coding in Python without the tab, indent & whitespace criteria?
63,086
false
15,517
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?
0.027266
10
16
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.
2008-09-15T13:55:00.000
10
python
22
68,061
Is there a way around coding in Python without the tab, indent & whitespace criteria?
63,086
false
15,517
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?
1
10
16
Emacs! Seriously, its use of "tab is a command, not a character", is absolutely perfect for python development.
2008-09-15T13:55:00.000
2
python
22
63,216
Is there a way around coding in Python without the tab, indent & whitespace criteria?
63,086
false
15,517
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?
0.01818
10
16
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?
2008-09-15T13:55:00.000
5
python
22
63,196
Is there a way around coding in Python without the tab, indent & whitespace criteria?
63,086
false
15,517
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?
0.045423
10
16
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.
2008-09-15T13:55:00.000
3
python
22
63,111
Is there a way around coding in Python without the tab, indent & whitespace criteria?
63,086
false
15,517
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?
0.027266
10
16
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
2008-09-15T13:55:00.000
3
python
22
63,095
Is there a way around coding in Python without the tab, indent & whitespace criteria?
63,086
false
15,517
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?
0.027266
10
16
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?
2008-09-15T13:55:00.000
5
python
22
63,819
Is there a way around coding in Python without the tab, indent & whitespace criteria?
63,086
false
15,517
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?
0.045423
10
16
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)
2008-09-15T13:55:00.000
6
python
22
63,119
Is there a way around coding in Python without the tab, indent & whitespace criteria?
63,086
false
15,517
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?
1
10
16
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.
2008-09-15T15:00:00.000
0
python,delphi
3
63,794
How create threads under Python for Delphi
63,681
false
1,259
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.
0
1
2
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.
2008-09-15T15:00:00.000
0
python,delphi
3
63,767
How create threads under Python for Delphi
63,681
false
1,259
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.
0
1
2
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.
2008-09-15T15:51:00.000
1
python,class
6
64,195
Classes in Python
64,141
false
1,205
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.
0.033321
1
2
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.
2008-09-15T15:51:00.000
1
python,class
6
64,206
Classes in Python
64,141
false
1,205
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.
0.033321
1
2
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.
2008-09-15T16:03:00.000
6
python,django
8
68,086
When to create a new app (with startapp) in Django?
64,237
false
35,690
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?
1
130
5
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.
2008-09-15T16:03:00.000
14
python,django
8
64,308
When to create a new app (with startapp) in Django?
64,237
false
35,690
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?
1
130
5
I tend to create new applications for each logically separate set of models. e.g.: User Profiles Forum Posts Blog posts
2008-09-15T16:03:00.000
1
python,django
8
67,769
When to create a new app (with startapp) in Django?
64,237
false
35,690
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?
0.024995
130
5
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.
2008-09-15T16:03:00.000
2
python,django
8
64,463,620
When to create a new app (with startapp) in Django?
64,237
false
35,690
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?
0.049958
130
5
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)
2008-09-15T16:03:00.000
24
python,django
8
64,464
When to create a new app (with startapp) in Django?
64,237
false
35,690
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?
1
130
5
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".
2008-09-15T16:27:00.000
1
python,client
11
256,833
Best Python supported server/client protocol?
64,426
false
8,856
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.
0.01818
9
2
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).
2008-09-15T16:27:00.000
4
python,client
11
256,826
Best Python supported server/client protocol?
64,426
false
8,856
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.
0.072599
9
2
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.
2008-09-15T17:48:00.000
3
python,vim,configuration,spaces
7
66,818
How do I set up Vim autoindentation properly for editing Python files?
65,076
false
120,959
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.
0.085505
89
1
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
2008-09-15T21:11:00.000
2
c++,boost-python
3
93,027
Using boost-python with C++ in Linux
67,015
false
3,149
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.
0.132549
3
2
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!
2008-09-15T21:11:00.000
2
c++,boost-python
3
67,282
Using boost-python with C++ in Linux
67,015
false
3,149
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.
0.132549
3
2
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.
2008-09-15T22:00:00.000
-1
python,django
10
67,477
Serving dynamically generated ZIP archives in Django
67,454
false
32,479
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.
-0.019997
68
2
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.
2008-09-15T22:00:00.000
1
python,django
10
73,617
Serving dynamically generated ZIP archives in Django
67,454
false
32,479
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.
0.019997
68
2
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).
2008-09-16T00:28:00.000
1
python,compiler-construction,programming-languages,interpreter
12
69,185
What's a good resource for starting to write a programming language, that's not context free?
68,243
false
2,008
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.
0.016665
14
5
Have you read Aho, Sethi, Ullman: "Compilers: Principles, Techniques, and Tools"? It is a classical language reference book. /Allan
2008-09-16T00:28:00.000
19
python,compiler-construction,programming-languages,interpreter
12
261,520
What's a good resource for starting to write a programming language, that's not context free?
68,243
false
2,008
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.
1
14
5
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).
2008-09-16T00:28:00.000
1
python,compiler-construction,programming-languages,interpreter
12
68,575
What's a good resource for starting to write a programming language, that's not context free?
68,243
false
2,008
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.
0.016665
14
5
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
2008-09-16T00:28:00.000
1
python,compiler-construction,programming-languages,interpreter
12
69,482
What's a good resource for starting to write a programming language, that's not context free?
68,243
false
2,008
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.
0.016665
14
5
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.
2008-09-16T00:28:00.000
2
python,compiler-construction,programming-languages,interpreter
12
315,462
What's a good resource for starting to write a programming language, that's not context free?
68,243
false
2,008
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.
0.033321
14
5
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.
2008-09-16T01:27:00.000
0
python,macos,libxml2
3
70,895
libxml2-p25 on OS X 10.5 needs sudo?
68,541
false
225
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?
0
0
2
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?
2008-09-16T01:27:00.000
0
python,macos,libxml2
3
77,114
libxml2-p25 on OS X 10.5 needs sudo?
68,541
false
225
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?
0
0
2
The PATH environment variable was the mistake.
2008-09-16T01:43:00.000
4
python,performance,list,tuples,python-internals
9
68,638
Are tuples more efficient than lists in Python?
68,630
false
113,174
Is there any performance difference between tuples and lists when it comes to instantiation and retrieval of elements?
0.088656
284
4
Tuples should be slightly more efficient and because of that, faster, than lists because they are immutable.
2008-09-16T01:43:00.000
9
python,performance,list,tuples,python-internals
9
71,295
Are tuples more efficient than lists in Python?
68,630
false
113,174
Is there any performance difference between tuples and lists when it comes to instantiation and retrieval of elements?
1
284
4
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.
2008-09-16T01:43:00.000
-6
python,performance,list,tuples,python-internals
9
53,385,158
Are tuples more efficient than lists in Python?
68,630
false
113,174
Is there any performance difference between tuples and lists when it comes to instantiation and retrieval of elements?
-1
284
4
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).
2008-09-16T01:43:00.000
41
python,performance,list,tuples,python-internals
9
70,968
Are tuples more efficient than lists in Python?
68,630
false
113,174
Is there any performance difference between tuples and lists when it comes to instantiation and retrieval of elements?
1
284
4
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.
2008-09-16T01:46:00.000
3
python,class,oop,static,class-variables
26
61,080,153
Static class variables and methods in Python
68,645
false
1,501,442
How do I create static class variables or methods in Python?
0.023073
2,352
2
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.
2008-09-16T01:46:00.000
5
python,class,oop,static,class-variables
26
79,840
Static class variables and methods in Python
68,645
false
1,501,442
How do I create static class variables or methods in Python?
0.038443
2,352
2
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).
2008-09-16T07:07:00.000
0
python,authentication,cgi
6
70,003
Can I implement a web user authentication system in python without POST?
69,979
false
2,893
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!
0
1
3
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.
2008-09-16T07:07:00.000
5
python,authentication,cgi
6
69,995
Can I implement a web user authentication system in python without POST?
69,979
true
2,893
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!
1.2
1
3
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.)
2008-09-16T07:07:00.000
1
python,authentication,cgi
6
69,989
Can I implement a web user authentication system in python without POST?
69,979
false
2,893
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!
0.033321
1
3
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
2008-09-16T09:44:00.000
19
python,input,command-line-arguments
12
70,869
How to prompt for user input and read command-line arguments
70,797
false
1,321,249
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
591
1
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
2008-09-16T11:44:00.000
1
java,python,command-line,ocsp
5
108,678
OCSP command-line test tool?
71,468
false
8,106
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
0.039979
3
1
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.
2008-09-16T12:46:00.000
1
python,metaclass
5
73,473
Using the docstring from one method to automatically overwrite that of another method
71,817
false
2,897
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.
0.039979
4
2
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
2008-09-16T12:46:00.000
0
python,metaclass
5
72,126
Using the docstring from one method to automatically overwrite that of another method
71,817
false
2,897
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.
0
4
2
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.
2008-09-16T15:35:00.000
0
python,termination
12
70,824,754
How to terminate a script?
73,663
false
1,876,007
I am aware of the die() command in PHP which exits a script early. How can I do this in Python?
0
1,288
2
Just put at the end of your code quit() and that should close a python script.
2008-09-16T15:35:00.000
75
python,termination
12
76,374
How to terminate a script?
73,663
false
1,876,007
I am aware of the die() command in PHP which exits a script early. How can I do this in Python?
1
1,288
2
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.
2008-09-16T16:44:00.000
3
.net,delphi,ironpython,unmanaged,ironruby
6
934,717
Using DLR from Unmanaged Code
74,386
false
877
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?
0.099668
5
1
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.
2008-09-16T16:49:00.000
1
python
8
76,404
Random in python 2.5 not working?
74,430
false
5,445
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?
0.024995
9
2
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.
2008-09-16T16:49:00.000
3
python
8
78,304
Random in python 2.5 not working?
74,430
false
5,445
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?
0.07486
9
2
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.
2008-09-16T18:26:00.000
43
python
5
75,456
How do I get the string with name of a class?
75,440
false
45,412
What method do I call to get the name of a class?
1
50
2
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.
2008-09-16T18:26:00.000
1
python
5
77,222
How do I get the string with name of a class?
75,440
false
45,412
What method do I call to get the name of a class?
0.039979
50
2
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'
2008-09-16T19:05:00.000
10
python,django,frameworks
9
1,997,668
Django -vs- Grails -vs-?
75,798
false
19,797
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?
1
23
5
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.
2008-09-16T19:05:00.000
10
python,django,frameworks
9
460,360
Django -vs- Grails -vs-?
75,798
false
19,797
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?
1
23
5
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.
2008-09-16T19:05:00.000
1
python,django,frameworks
9
81,699
Django -vs- Grails -vs-?
75,798
false
19,797
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?
0.022219
23
5
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.
2008-09-16T19:05:00.000
1
python,django,frameworks
9
76,198
Django -vs- Grails -vs-?
75,798
false
19,797
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?
0.022219
23
5
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.
2008-09-16T19:05:00.000
32
python,django,frameworks
9
1,955,727
Django -vs- Grails -vs-?
75,798
true
19,797
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?
1.2
23
5
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!
2008-09-16T19:08:00.000
4
python,sql,sqlalchemy
3
77,962
Best way to access table instances when using SQLAlchemy's declarative syntax
75,829
false
2,919
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?
0.26052
8
2
via the __table__ attribute on your declarative class
2008-09-16T19:08:00.000
0
python,sql,sqlalchemy
3
315,406
Best way to access table instances when using SQLAlchemy's declarative syntax
75,829
false
2,919
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?
0
8
2
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.
2008-09-16T20:11:00.000
3
python,ruby,perl,security,penetration-testing
12
76,441
Which of these scripting languages is more appropriate for pen-testing?
76,408
false
6,338
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.
0.049958
6
7
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.
2008-09-16T20:11:00.000
0
python,ruby,perl,security,penetration-testing
12
76,470
Which of these scripting languages is more appropriate for pen-testing?
76,408
false
6,338
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.
0
6
7
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.
2008-09-16T20:11:00.000
1
python,ruby,perl,security,penetration-testing
12
76,495
Which of these scripting languages is more appropriate for pen-testing?
76,408
false
6,338
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.
0.016665
6
7
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.
2008-09-16T20:11:00.000
1
python,ruby,perl,security,penetration-testing
12
76,508
Which of these scripting languages is more appropriate for pen-testing?
76,408
false
6,338
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.
0.016665
6
7
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.
2008-09-16T20:11:00.000
3
python,ruby,perl,security,penetration-testing
12
78,106
Which of these scripting languages is more appropriate for pen-testing?
76,408
false
6,338
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.
0.049958
6
7
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 :)
2008-09-16T20:11:00.000
0
python,ruby,perl,security,penetration-testing
12
4,927,367
Which of these scripting languages is more appropriate for pen-testing?
76,408
false
6,338
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.
0
6
7
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.
2008-09-16T20:11:00.000
8
python,ruby,perl,security,penetration-testing
12
77,717
Which of these scripting languages is more appropriate for pen-testing?
76,408
false
6,338
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.
1
6
7
[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.
2008-09-16T20:48:00.000
2
python,vba,porting
8
189,311
Resources for Python Programmer
76,882
false
9,282
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?
0.049958
21
3
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.
2008-09-16T20:48:00.000
2
python,vba,porting
8
76,989
Resources for Python Programmer
76,882
false
9,282
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?
0.049958
21
3
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).
2008-09-16T20:48:00.000
25
python,vba,porting
8
186,583
Resources for Python Programmer
76,882
false
9,282
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?
1
21
3
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).
2008-09-16T21:05:00.000
7
php,python,performance,pylons
10
33,627,050
Which is faster, python webpages or php webpages?
77,086
false
58,657
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.
1
41
9
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.
2008-09-16T21:05:00.000
1
php,python,performance,pylons
10
77,093
Which is faster, python webpages or php webpages?
77,086
false
58,657
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.
0.019997
41
9
If it ain't broke don't fix it. Just write a quick test, but bear in mind that each language will be faster with certain functions then the other.