Available Count
int64 1
31
| AnswerCount
int64 1
35
| GUI and Desktop Applications
int64 0
1
| Users Score
int64 -17
588
| Q_Score
int64 0
6.79k
| Python Basics and Environment
int64 0
1
| Score
float64 -1
1.2
| Networking and APIs
int64 0
1
| Question
stringlengths 15
7.24k
| Database and SQL
int64 0
1
| Tags
stringlengths 6
76
| CreationDate
stringlengths 23
23
| System Administration and DevOps
int64 0
1
| Q_Id
int64 469
38.2M
| Answer
stringlengths 15
7k
| Data Science and Machine Learning
int64 0
1
| ViewCount
int64 13
1.88M
| is_accepted
bool 2
classes | Web Development
int64 0
1
| Other
int64 1
1
| Title
stringlengths 15
142
| A_Id
int64 518
72.2M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3 | 4 | 0 | 3 | 1 | 1 | 1.2 | 0 | I decided to rewrite all our Bash scripts in Python (there are not so many of them) as my first Python project. The reason for it is that although being quite fluent in Bash I feel it's somewhat archaic language and since our system is in the first stages of its developments I think switching to Python now will be the right thing to do.
Are there scripts that should always be written in Bash? For example, we have an init.d daemon script - is it OK to use Python for it?
We run CentOS.
Thanks. | 0 | python,linux,bash,scripting | 2010-05-17T20:13:00.000 | 1 | 2,852,397 | It is OK in the sense that you can do it. But the scripts in /etc/init.d usually need to load config data and some functions (for example to print the nice green OK on the console) which will be hard to emulate in Python.
So try to convert those which make sense (i.e. those which contain complex logic). If you need job control (starting/stopping processes), then bash is better suited than Python. | 0 | 387 | true | 0 | 1 | What scripts should not be ported from bash to python? | 2,852,418 |
3 | 4 | 0 | 1 | 1 | 1 | 0.049958 | 0 | I decided to rewrite all our Bash scripts in Python (there are not so many of them) as my first Python project. The reason for it is that although being quite fluent in Bash I feel it's somewhat archaic language and since our system is in the first stages of its developments I think switching to Python now will be the right thing to do.
Are there scripts that should always be written in Bash? For example, we have an init.d daemon script - is it OK to use Python for it?
We run CentOS.
Thanks. | 0 | python,linux,bash,scripting | 2010-05-17T20:13:00.000 | 1 | 2,852,397 | Every task has languages that are better suited for it and less so. Replacing the backtick ` quote of sh is pretty ponderous in Python as would be myriad quoting details, just to name a couple. There are likely better projects to cut your teeth on.
And all that they said above about Python being relatively heavyweight and not necessarily available when needed. | 0 | 387 | false | 0 | 1 | What scripts should not be ported from bash to python? | 2,853,661 |
1 | 6 | 0 | 60 | 28 | 0 | 1.2 | 0 | Do you know any PHP statement that works like Python's pass statement? | 0 | php,python,language-comparisons | 2010-05-17T21:01:00.000 | 0 | 2,852,784 | Just leave the bracket's empty...
Python has the pass word because they don't use brackets to define the body part of classes, function, and other statement. PHP doesn't have this dilemma , and therefore doesn't need something to say that a body statement is empty. | 0 | 22,582 | true | 0 | 1 | What is the equivalent in PHP for Python's pass statement? | 2,852,795 |
1 | 1 | 0 | 13 | 6 | 0 | 1.2 | 0 | I am struggling to find any method of using RSA in ECB mode with PKCS1 padding in python. I've looked into pyCrypto, but they don't have PKCS1 padding in the master branch (but do in a patch). Nevertheless I found RSA with PKCS1 in the M2Crypto package, but I'm not sure if I can choose ECB mode... | 0 | python,encryption,rsa | 2010-05-18T07:44:00.000 | 0 | 2,855,326 | Chaining mode such as ECB makes no sense for RSA, unless you are doing it wrong.
ECB is for block ciphers: the input data is split into equal-size blocks, and each block is encrypted separately. This induces some weaknesses so ECB mode is best avoided for block ciphers.
RSA is not a block cipher. In particular, RSA necessarily enlarges the encrypted message: with a 1024-bit RSA key (a fairly typical size), one can encrypt a message up to 117 bytes, but the result is a 128-byte value.
One could imagine taking a larger message, split it into individual blocks of length 117 bytes (or less) and RSA-encrypt each of them individually, but nobody ever does that, mostly because of the size increase, and the CPU cost. Also, security issues related to that splitting and recombining are not studied at all, so it is quite possible that the result would be quite weak. Usually, when a cryptographic library requires a padding mode as part of an algorithm name, such as in "RSA/ECB/PKCS1Padding", this is only due to the syntaxic constraints on the name, and the chaining part (ECB) is actually ignored (this is what Java does, for instance).
In practice, when encrypting some data which may be larger than the maximum RSA input size, hybrid encryption is used: what is RSA-encrypted is a random symmetric key (e.g. a bunch of 16 uniformly random bytes), and that key is used to symmetrically encrypt (e.g. with AES) the actual data. This is more space-effective (because symmetric encryption does not enlarge blocks) and CPU-efficient (symmetric encryption is vastly faster than asymmetric encryption, and in particular RSA decryption). | 0 | 9,374 | true | 0 | 1 | How can I create a key using RSA/ECB/PKCS1Padding in python? | 2,856,628 |
1 | 4 | 0 | 10 | 78 | 1 | 1 | 0 | There are many sites with instructions on installing ropemacs, but so far I couldn't find any with instructions on how to use it after it's already installed. I have it installed, or at least it seems so, Emacs has "Rope" menu in it's top menu bar. Now what? So far I could use only "Show documentation" (C-c d by default). An attempt to use code assist (which is auto-complete, I presume?) only causes Emacs to ask about "Rope project root folder" (what's that?) in the minibuffer and then showing nothing.
So, once ropemacs is installed, what are the steps to see it in action on some simple python scripts? Something like "if you have this script in your emacs and put the blinking square here and press this, it does that" would be an answer.
(I've been thinking if I should ask this or not for some time, because nobody else seems to have the same problem) | 0 | python,emacs,ide,autocomplete | 2010-05-18T07:52:00.000 | 0 | 2,855,378 | You can set the root folder with rope-open-project . Once you've set the root project a .ropeproject dir will be created.
Inside it, a config.py file has hooks where you can run (python) code once the project is set. The project_opened(project): function is a good place to run code. I usually activate the virtual environment imp.load_source('/path-to-env/activate_this.py') , so that I can get source coverage for other libs in the virtual env. | 0 | 18,010 | false | 0 | 1 | ropemacs USAGE tutorial | 2,858,148 |
1 | 1 | 0 | 1 | 0 | 0 | 0.197375 | 0 | How do you guys deploy your code on your servers? I am using Fabric and Python and I would like a more automated way of pulling code from the repository through the use of public keys, but without any ops or manual intervention to set up the public keys.
Are you storing them in the code as text or in a database and generate the pk file on the fly? Any other opinions on this one ? | 0 | python,fabric | 2010-05-18T08:34:00.000 | 0 | 2,855,650 | This is what ssh-copy-id is for. It deploys your public key onto a machine for you. Key management isn't something I'd suggest putting into code/VCS. Each user needs to setup their keys so that the local ssh client knows to use them. We use Fabric as well, but it only uses the key that the ssh config is already telling it to. | 0 | 212 | false | 1 | 1 | deployment public keys | 2,857,218 |
1 | 3 | 0 | 2 | 5 | 0 | 0.132549 | 0 | I have a WSGI app that I would like to place behind SSL. My WSGI server is gevent.
What would a good way to serve the app through SSL in this case be? | 0 | python,ssl,wsgi,gevent | 2010-05-18T12:40:00.000 | 0 | 2,857,273 | I would let the http server deal with the ssl transport. | 0 | 7,474 | false | 1 | 1 | SSL and WSGI apps - Python | 2,857,301 |
2 | 2 | 0 | 1 | 3 | 0 | 0.099668 | 0 | I've been using for more than 12 years PHP with Apache (a.k.a mod_php) for my web
development work. I've recenlty discovered python and its real power (I still don't understand why this is not always the best product that becomes the most famous).
I've just discovered mod_python for Apache. I've already googled but without success things like mod_python vs mod_php. I wanted to know the differences between the two mod_php and mod_python in terms of:
speed
productivity
maintainance
(I know `python is most productive and maintainable language in the world, but is it the same for Web programming with Apache)
availability of features e.g, cookies and session handling, databases, protocols, etc. | 0 | apache,mod-python,mod-php | 2010-05-19T07:36:00.000 | 0 | 2,863,618 | I wanted to know the differences between the two mod_php and mod_python...
PHP is more widely available on Internet hosts than Python.
I've noticed on one of my Python web sites that if I'm the first user to use Python, on that Internet host, the start up time of the Python services can be measured in minutes. Most people won't wait minutes for a web page to pop up.
Python has the same web features (cookies, session handling, database connections, protocols) as PHP. | 0 | 1,262 | false | 0 | 1 | Web programming: Apache modules: mod_python vs mod_php | 2,863,923 |
2 | 2 | 0 | 2 | 3 | 0 | 1.2 | 0 | I've been using for more than 12 years PHP with Apache (a.k.a mod_php) for my web
development work. I've recenlty discovered python and its real power (I still don't understand why this is not always the best product that becomes the most famous).
I've just discovered mod_python for Apache. I've already googled but without success things like mod_python vs mod_php. I wanted to know the differences between the two mod_php and mod_python in terms of:
speed
productivity
maintainance
(I know `python is most productive and maintainable language in the world, but is it the same for Web programming with Apache)
availability of features e.g, cookies and session handling, databases, protocols, etc. | 0 | apache,mod-python,mod-php | 2010-05-19T07:36:00.000 | 0 | 2,863,618 | My understanding is that PHP was designed with Internet/Web in mind, but Python is for a more general purpose.
Now most people are leaving mod_python for mod_wsgi, which is more robust and flexible.
To answer other questions:
speed: python is faster. (PHP is slower than both ruby and python)
productivity: at least the same as php with numerous libraries
maintenance: python is clear and neat
features: more than you need, I would say.
Python was not popular on web because it wasn't focused on web at all. It has too many web frameworks (more frameworks than programming languages), so the community has not been as strong as Ruby on Rails. | 0 | 1,262 | true | 0 | 1 | Web programming: Apache modules: mod_python vs mod_php | 2,869,850 |
1 | 2 | 0 | 1 | 4 | 0 | 0.099668 | 0 | I have a project which is essentially a game server where users connect and send text commands via telnet.
The code is in C and really old and unmodular and has several bugs and missing features. The main function alone is half the code.
I came to the conclusion that rewriting it in Python, with Twisted, could actually result in faster completement, besides other benefits.
So, here is the questions:
What packages and modules I should use? I see a "telnet" module inside "protocols" package. I also see "cronch" package with "ssh" and another "telnet" module.
I'm a complete novice regarding Python. | 0 | python,twisted,telnet | 2010-05-19T10:33:00.000 | 1 | 2,864,663 | It sounds like you've got two separate tasks here:
Port the code from C to Python.
Rewrite the whole program to use Twisted.
Since you're new to Python, I would be inclined to do the first one first, before trying to make the program structure work in Twisted. If the program is old, there isn't likely to be any performance problems running it on modern hardware.
Converting the C code to Python first will give you the familiarity with Python you need to start on the port to Twisted. | 0 | 2,482 | false | 0 | 1 | Twisted Matrix and telnet server implementation | 2,864,683 |
10 | 18 | 0 | 1 | 76 | 0 | 0.011111 | 0 | I just finished my second year as a university CS student, so my "real-world" knowledge is lacking. I learned Java my first year, continued with Java and picked up C and simple Bash
scripting my second. This summer I'm trying to learn Perl (God help me). I've dabbled with Python a bit in the past.
My question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts? Is there something I'm missing? I know my linux box has perl and python. Are they not ubiquitous enough? Is there really something
that's easier to do in Bash than in some other hll? | 0 | python,perl,bash,scripting,comparison | 2010-05-20T08:20:00.000 | 1 | 2,872,041 | What I don't get is why people say bash when they mean any bourne-shell compatible shell.
When writing shell scripts: always try to use constructs that also work in older bourne shell interpreters as well. It will save you lots of trouble some day.
And yes, there is plenty of use for shell scripts today, as the shell always exist on all unixes, out of the box, contrary to perl, python, csh, zsh, ksh (possibly?), and so on.
Most of the time they only add extra convenience or different syntax for constructs like loops and tests. Some have improved redirection features.
Most of the time, I would say that ordinary bourne shell works equally well.
Typical pitfall:
if ! test $x -eq $y works as expected in bash that has a more clever builtin "if" operator, but the "correct" if test ! $x -eq $y should work in all environments. | 0 | 50,948 | false | 0 | 1 | Is there any use for Bash scripting anymore? | 3,203,607 |
10 | 18 | 0 | 1 | 76 | 0 | 0.011111 | 0 | I just finished my second year as a university CS student, so my "real-world" knowledge is lacking. I learned Java my first year, continued with Java and picked up C and simple Bash
scripting my second. This summer I'm trying to learn Perl (God help me). I've dabbled with Python a bit in the past.
My question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts? Is there something I'm missing? I know my linux box has perl and python. Are they not ubiquitous enough? Is there really something
that's easier to do in Bash than in some other hll? | 0 | python,perl,bash,scripting,comparison | 2010-05-20T08:20:00.000 | 1 | 2,872,041 | As mentioned, the GNU tools are great, and are easiest to use within the shell. It is especially nice if your data is already in a linear or tabular form of plain text. Just as an example, the other day I was able to build a script to create an XHTML word cloud of any text file in 8 lines of Bourne Shell, which is even less powerful (but more widely supported) than Bash. | 0 | 50,948 | false | 0 | 1 | Is there any use for Bash scripting anymore? | 3,147,413 |
10 | 18 | 0 | 2 | 76 | 0 | 0.022219 | 0 | I just finished my second year as a university CS student, so my "real-world" knowledge is lacking. I learned Java my first year, continued with Java and picked up C and simple Bash
scripting my second. This summer I'm trying to learn Perl (God help me). I've dabbled with Python a bit in the past.
My question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts? Is there something I'm missing? I know my linux box has perl and python. Are they not ubiquitous enough? Is there really something
that's easier to do in Bash than in some other hll? | 0 | python,perl,bash,scripting,comparison | 2010-05-20T08:20:00.000 | 1 | 2,872,041 | I'm a perl guy, but the number of the bash (or ksh) functions I use and create on a daily basis is quite significant. For anything involved, I'll write a perl script, but for navigating the directory structure, and specifically for manipulating environment variables bash/ksh/... are indispensable.
Again, especially for environment variables nothing beats shell, and quite a few programs use environment variables. In Perl, I have to write a bash alias or function that calls the Perl script, which writes out a temporary bash script, which then gets sourced after Perl exits in order to make the change in the same environment I'm launching from.
I've done this, especially for heavy-lifting on path variables. But there's no way to do it in just Perl (or python or ruby... or C-code for that matter). | 0 | 50,948 | false | 0 | 1 | Is there any use for Bash scripting anymore? | 2,877,257 |
10 | 18 | 0 | 1 | 76 | 0 | 0.011111 | 0 | I just finished my second year as a university CS student, so my "real-world" knowledge is lacking. I learned Java my first year, continued with Java and picked up C and simple Bash
scripting my second. This summer I'm trying to learn Perl (God help me). I've dabbled with Python a bit in the past.
My question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts? Is there something I'm missing? I know my linux box has perl and python. Are they not ubiquitous enough? Is there really something
that's easier to do in Bash than in some other hll? | 0 | python,perl,bash,scripting,comparison | 2010-05-20T08:20:00.000 | 1 | 2,872,041 | In my experience, Perl meets something like 99% of any need that might require a shell script. As a bonus, it is possible to write code that runs on Windows sans Cygwin. If I won't have a Perl install on a Windows box I want to target, I can use PAR::Packer or PerlApp to produce an executable. Python, Ruby and others should work just as well, too.
However, shell scripting isn't all that complicated--at least things that you should be scripting in a shell aren't all that complicated. You can do what you need to do with a fairly shallow level of knowledge.
Learn how to read and set variables. How to create and call functions. How to source other files. Learn how flow control works.
And most important, learn to read the shell man page. This may sound facetious, but I am 100% serious--don't worry about cramming every detail of shell scripting into your brain, instead learn to find what you need to know in the man page quickly and efficiently. If you find yourself using shell scripting often, the pertinent info will naturally stick in your brain.
So, yes, basic shell is worth learning. | 0 | 50,948 | false | 0 | 1 | Is there any use for Bash scripting anymore? | 2,875,733 |
10 | 18 | 0 | 2 | 76 | 0 | 0.022219 | 0 | I just finished my second year as a university CS student, so my "real-world" knowledge is lacking. I learned Java my first year, continued with Java and picked up C and simple Bash
scripting my second. This summer I'm trying to learn Perl (God help me). I've dabbled with Python a bit in the past.
My question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts? Is there something I'm missing? I know my linux box has perl and python. Are they not ubiquitous enough? Is there really something
that's easier to do in Bash than in some other hll? | 0 | python,perl,bash,scripting,comparison | 2010-05-20T08:20:00.000 | 1 | 2,872,041 | Easier, probably not. I actually prefer perl to bash scripting in many cases. Bash does have one advantage, though, especially on Linux systems: it's all but guaranteed to be installed. And if it's not, its largely-compatible father (sh) will be, cause almost all system scripts are written for sh. Even perl isn't that ubiquitous, and it's everyfreakingwhere. | 0 | 50,948 | false | 0 | 1 | Is there any use for Bash scripting anymore? | 2,872,083 |
10 | 18 | 0 | 8 | 76 | 0 | 1 | 0 | I just finished my second year as a university CS student, so my "real-world" knowledge is lacking. I learned Java my first year, continued with Java and picked up C and simple Bash
scripting my second. This summer I'm trying to learn Perl (God help me). I've dabbled with Python a bit in the past.
My question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts? Is there something I'm missing? I know my linux box has perl and python. Are they not ubiquitous enough? Is there really something
that's easier to do in Bash than in some other hll? | 0 | python,perl,bash,scripting,comparison | 2010-05-20T08:20:00.000 | 1 | 2,872,041 | Well, when writing with bash, you can directly use every possible tool you have on the command line for your script. With any other language you would first have to execute that command and get some result etc. A simple script that (for example) gets a list of processes, runs through grep and gets some result would be a lot more complicated in other languages. As such, bash is still a good tool for writing quick things. | 0 | 50,948 | false | 0 | 1 | Is there any use for Bash scripting anymore? | 2,872,064 |
10 | 18 | 0 | 2 | 76 | 0 | 0.022219 | 0 | I just finished my second year as a university CS student, so my "real-world" knowledge is lacking. I learned Java my first year, continued with Java and picked up C and simple Bash
scripting my second. This summer I'm trying to learn Perl (God help me). I've dabbled with Python a bit in the past.
My question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts? Is there something I'm missing? I know my linux box has perl and python. Are they not ubiquitous enough? Is there really something
that's easier to do in Bash than in some other hll? | 0 | python,perl,bash,scripting,comparison | 2010-05-20T08:20:00.000 | 1 | 2,872,041 | If you do lots of GUI stuff, you'll probably only meet bash whenever you're doing some sort of customization on your own machine. Various hacks and stuff. If you use the command line to do stuff, bash is just indispensable. In fact, being good on the command line requires bash or some other shell familiarity.
I get miles out of having learned Bash when I wanted to navigate around my harddrive quickly. I wrote a navigation/menu interface that let me beam to different folders and files quickly and easily. Writing it in bash was simple and easy. And there's lots of easily accessed, and free, stuff that'll show you how.
Also, learning Bash is great for understanding how Unix and some of the core stuff really works -- and how far we've come with tools like Python. | 0 | 50,948 | false | 0 | 1 | Is there any use for Bash scripting anymore? | 2,874,267 |
10 | 18 | 0 | 4 | 76 | 0 | 0.044415 | 0 | I just finished my second year as a university CS student, so my "real-world" knowledge is lacking. I learned Java my first year, continued with Java and picked up C and simple Bash
scripting my second. This summer I'm trying to learn Perl (God help me). I've dabbled with Python a bit in the past.
My question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts? Is there something I'm missing? I know my linux box has perl and python. Are they not ubiquitous enough? Is there really something
that's easier to do in Bash than in some other hll? | 0 | python,perl,bash,scripting,comparison | 2010-05-20T08:20:00.000 | 1 | 2,872,041 | Apart from what others have said, I'd like to point out what's in my opinion the main reason to learn Bash: it's the (almost) standard Linux shell.
Other scripting languages are surely useful, and maybe a lot more powerful, but what you'll be dealing with when you have a terminal in front of you is... Bash.
Being able to manage I/O, pipes and processes, assing and use variables, and do at least some loop and condition evaluation is a must, if you want to manage a Linux system. | 0 | 50,948 | false | 0 | 1 | Is there any use for Bash scripting anymore? | 2,875,677 |
10 | 18 | 0 | 2 | 76 | 0 | 0.022219 | 0 | I just finished my second year as a university CS student, so my "real-world" knowledge is lacking. I learned Java my first year, continued with Java and picked up C and simple Bash
scripting my second. This summer I'm trying to learn Perl (God help me). I've dabbled with Python a bit in the past.
My question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts? Is there something I'm missing? I know my linux box has perl and python. Are they not ubiquitous enough? Is there really something
that's easier to do in Bash than in some other hll? | 0 | python,perl,bash,scripting,comparison | 2010-05-20T08:20:00.000 | 1 | 2,872,041 | Bash (and the original Bourne sh and myriad derivatives) is - from one perspective - an incredibly high-level language. Where many languages use simple primitives, shell primitives are entire programs.
That it might not be the best language to express your tasks, doesn't mean it is dead, dying, or even moribund. | 0 | 50,948 | false | 0 | 1 | Is there any use for Bash scripting anymore? | 2,872,085 |
10 | 18 | 0 | 26 | 76 | 0 | 1 | 0 | I just finished my second year as a university CS student, so my "real-world" knowledge is lacking. I learned Java my first year, continued with Java and picked up C and simple Bash
scripting my second. This summer I'm trying to learn Perl (God help me). I've dabbled with Python a bit in the past.
My question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts? Is there something I'm missing? I know my linux box has perl and python. Are they not ubiquitous enough? Is there really something
that's easier to do in Bash than in some other hll? | 0 | python,perl,bash,scripting,comparison | 2010-05-20T08:20:00.000 | 1 | 2,872,041 | The real difference between bash and python is that python is a general purpose scripting language, while bash is simply a way to run a myriad of small (and often very fast) programs in a series. Python can do this, but it is not optimized for it. The programs (sort, find, uniq, scp) might do very complex tasks very simply, and bash allows these tasks to interoperate very simply with piping, flushing output in and out from files or devices etc. While Python can run the same programs, you will be forced to do bash scripting in the python script to accomplish the same thing, and then you are stuck with both python and bash. Both are fine by them self, but a mix of these don't improve anything IMHO. | 0 | 50,948 | false | 0 | 1 | Is there any use for Bash scripting anymore? | 2,872,171 |
2 | 3 | 0 | 5 | 1 | 1 | 1.2 | 0 | My config file is really just a big python dict, but I have many config files to run different experiments and I want to 'import' a different one based on a command line option. Instinctively I want to do import ConfigFileName where ConfigFileName is a string with the config file's python package name in it... but that doesn't work.
Any ideas? | 0 | python,configuration,import,config | 2010-05-20T14:02:00.000 | 0 | 2,874,431 | Use the __import__ builtin function. But like nosklo, I prefer to store it in simpler data format like JSON of INI config file. | 0 | 564 | true | 0 | 1 | What's the best way to use python-syntax config files (in python of course)? | 2,874,547 |
2 | 3 | 0 | 1 | 1 | 1 | 0.066568 | 0 | My config file is really just a big python dict, but I have many config files to run different experiments and I want to 'import' a different one based on a command line option. Instinctively I want to do import ConfigFileName where ConfigFileName is a string with the config file's python package name in it... but that doesn't work.
Any ideas? | 0 | python,configuration,import,config | 2010-05-20T14:02:00.000 | 0 | 2,874,431 | You might consider ConfigParser, also included with python. It offers simple sectioned name/value items, default settings, and some substitution capabilities. If that's flexible enough for your needs, it would be a nice alternative. | 0 | 564 | false | 0 | 1 | What's the best way to use python-syntax config files (in python of course)? | 2,877,557 |
1 | 2 | 0 | 0 | 3 | 0 | 0 | 0 | I'm trying to find a decent IDE that supports Python 3.x, and offers code completion/in-built Pydocs viewer, Mercurial integration, and SSH/SFTP support.
Anyhow, I'm trying Pydev, and I open up a .py file, it's in the Pydev perspective and the Run As doesn't offer any options. It does when you start a Pydev project, but I don't want to start a project just to edit one single Python script, lol, I want to just open a .py file and have It Just Work...
Plan 2, I try Komodo 6 Alpha 2. I actually quite like Komodo, and it's nice and snappy, offers in-built Mercurial support, as well as in-built SSH support (although it lacks SSH HTTP Proxy support, which is slightly annoying).
However, for some reason, this refuses to pick up Python 3. In Edit-Preferences-Languages, there's two option, one for Python and Python3, but the Python3 one refuses to work, with either the official Python.org binaries, or ActiveState's own ActivePython 3. Of course, I can set the "Python" interpreter to the 3.1 binary, but that's an ugly hack and breaks Python 2.x support.
So, does anybody who uses an IDE for Python have any suggestions on either of these accounts, or can you recommend an alternate IDE for Python 3.0 development?
Cheers,
Victor | 0 | python,ide | 2010-05-21T01:18:00.000 | 1 | 2,879,008 | You did not mention these so I'm not sure if you've tried them but there are:
- Aptana (aptana.com)
- The Eric Python IDE (http://eric-ide.python-projects.org/)
- WingWare Python IDE (wingware.com)
I haven't used any of them so I don't know if they will match your needs, but I'd expected them to be pretty close as they are all mature.
As for PyCharm, I've been using it for a while and it's fine, actully I like it very much.
However I'm a Python noob and probably do not use many advanced features so YMMV. | 0 | 584 | false | 0 | 1 | Python 3.0 IDE - Komodo and Eclipse both flaky? | 11,520,785 |
1 | 3 | 0 | 1 | 11 | 0 | 0.066568 | 0 | I have a system where a central Java controller launches analysis processes, which may be written in C++, Java, or Python (mostly they are C++). All these processes currently run on the same server. What are you suggestions to
Create a central log to which all processes can write to
What if in the future I push some processes to another server. How can I support distributed logging?
Thanks! | 0 | java,c++,python,logging | 2010-05-21T21:49:00.000 | 1 | 2,885,822 | I'd use Apache log4cxx or Apache log4j.
It's Efficient. It has Logger hierarchies to modularize your logs. It's proven tecnology for a while now.
Currently, appenders exist for the console , files , GUI components, remote socket servers, NT Event Loggers , and remote UNIX Syslog daemons. It is also possible to log asynchronously.
How can I support distributed logging?
With remote socket servers appenders for example. | 0 | 2,806 | false | 1 | 1 | Which logging library to use for cross-language (Java, C++, Python) system | 2,926,570 |
3 | 4 | 0 | 4 | 0 | 1 | 0.197375 | 0 | in python tutorial added that python cannot hide its attributes from other classes. some thing such as private data in C++ or java..But also i know that we can use _ or __ to set some variables as privated one but it is not enogh. I think it is a weak if it is not any thing to do it. | 0 | python | 2010-05-22T12:18:00.000 | 0 | 2,888,035 | Data encapsulation in Python is enforced by convention and peer review. Surprisingly, having every attribute effectively be public hasn't caused a problem for the majority of Python programmers. | 0 | 5,646 | false | 0 | 1 | information hiding in python | 2,888,059 |
3 | 4 | 0 | 4 | 0 | 1 | 0.197375 | 0 | in python tutorial added that python cannot hide its attributes from other classes. some thing such as private data in C++ or java..But also i know that we can use _ or __ to set some variables as privated one but it is not enogh. I think it is a weak if it is not any thing to do it. | 0 | python | 2010-05-22T12:18:00.000 | 0 | 2,888,035 | Using an underscore at the start of the name for an element or a method signals to the reader that what they're looking at is "internal implementation details". If they want to use that, they can, but it is very likely that a new version of the class will not preserve the API for internal-only method or elements (eh, "slots", I guess, the instance variables).
By having compiler-enforced guarantees as to what is and isn't visible, you are more sure that external parties are not looking at the internal bits, but even in C++ it is not that hard to access private things.
In practice, as long as you trust people not to do stupid things there's no problem having "this is internal, don't touch" as a polite reminder rather than enforced. | 0 | 5,646 | false | 0 | 1 | information hiding in python | 2,888,071 |
3 | 4 | 0 | 2 | 0 | 1 | 0.099668 | 0 | in python tutorial added that python cannot hide its attributes from other classes. some thing such as private data in C++ or java..But also i know that we can use _ or __ to set some variables as privated one but it is not enogh. I think it is a weak if it is not any thing to do it. | 0 | python | 2010-05-22T12:18:00.000 | 0 | 2,888,035 | You are right that the _foo convention isn't sufficient to make data private; it's not supposed to be! Information hiding is not part of the design of Python. When writing programs in Python, you depend on the caller's good manners to leave your internals alone based on the naming convention and your documentation. Don't try to exert more control than this; we're all consenting adults.
There is a convention of naming internal-use methods like _foo with a single leading underscore; this serves more documentation purposes than anything else. Python name-mangles __foo attributes. Some people think this makes them more private, but it doesn't make them at all private, though it does make your classes harder to use, extend, and test. I never use them. | 0 | 5,646 | false | 0 | 1 | information hiding in python | 2,888,448 |
2 | 3 | 0 | 6 | 3 | 0 | 1 | 0 | I need huffman code(best in python or in java), which could encode text not by one character (a = 10, b = 11), but by two (ab = 11, ag = 10). Is it possible and if yes, where could i find it, maybe it's somewhere in the internet and i just can'd find it? | 0 | java,python,huffman-code | 2010-05-22T14:36:00.000 | 0 | 2,888,468 | Huffman code doesn't care about characters, it cares about symbols. Generally, it is used to encode the alphabet / other single characters, but can very easily be generalized to encode strings of characters. Basically, you would just take an existing implementation and allow symbols to be strings rather than characters. A leaf node would then correspond to a list of strings. | 0 | 1,395 | false | 1 | 1 | Huffman coding two characters as one | 2,888,480 |
2 | 3 | 0 | 0 | 3 | 0 | 0 | 0 | I need huffman code(best in python or in java), which could encode text not by one character (a = 10, b = 11), but by two (ab = 11, ag = 10). Is it possible and if yes, where could i find it, maybe it's somewhere in the internet and i just can'd find it? | 0 | java,python,huffman-code | 2010-05-22T14:36:00.000 | 0 | 2,888,468 | There is probably some code somewhere. But this sounds like a parsing and tokenising question. One of the first questions I would be answering is how many unique pairs are you dealing with. Huffman encoding works best with small numbers of tokens. For example, the 101 characters on your keyboard. But if your two characters can be anything, you are now expanding the maximum number of characters massively. | 0 | 1,395 | false | 1 | 1 | Huffman coding two characters as one | 2,888,494 |
1 | 2 | 0 | 3 | 1 | 0 | 1.2 | 0 | We have discussion in my job place about question (We use 1 of the php frameworks):
Why program with php frameworks big web application if it can be done better with ruby on rails, python or java?
Please say our opinion
thanks | 0 | java,php,python,ruby-on-rails,django | 2010-05-23T07:56:00.000 | 0 | 2,891,017 | If you only know PHP and you don't feel like learning Ruby/Python/Java. Seriously, if it can be done better with another tool, it should be done with another tool. Of course, this assumes the other tools are actually better. That part is arguable. Some people are so stuck up on their "my way is the best way" that they leave out the "because it's the only way I know" part. | 0 | 240 | true | 1 | 1 | Why program with php frameworks if it can be done better with ruby on rails, python or java? | 2,891,024 |
3 | 5 | 0 | 7 | 5 | 1 | 1 | 0 | Reasoning: I'm trying to convert a large library from Scheme to Python
Are there any good strategies for doing this kind of conversion? Specifically cross-paradigm in this case since Python is more OO and Scheme is Functional.
Totally subjective so I'm making it community wiki | 0 | python,scheme,code-translation | 2010-05-23T20:29:00.000 | 0 | 2,893,313 | I would treat the original language implementation almost like a requirements specification, and write up a design based on it (most importantly including detailed interface definitions, both for the external interfaces and for those between modules within the library). Then I would implement from that design.
What I would most definitely NOT do is any kind of function-by-function translation. | 0 | 193 | false | 0 | 1 | Advice on translating code from very unrelated languages (in this case Scheme to Python)? | 2,893,338 |
3 | 5 | 0 | 0 | 5 | 1 | 0 | 0 | Reasoning: I'm trying to convert a large library from Scheme to Python
Are there any good strategies for doing this kind of conversion? Specifically cross-paradigm in this case since Python is more OO and Scheme is Functional.
Totally subjective so I'm making it community wiki | 0 | python,scheme,code-translation | 2010-05-23T20:29:00.000 | 0 | 2,893,313 | If you don't have time to do as the others have suggested and actually re-implement the functionality, there is no reason you CAN'T implement it in a strictly functional fashion.
Python supports the key features necessary to do functional programming, and you might find that your time was better spent doing other things, especially if absolute optimization is not required. On the other hand, you might find bug-hunting to be quite hard. | 0 | 193 | false | 0 | 1 | Advice on translating code from very unrelated languages (in this case Scheme to Python)? | 2,893,602 |
3 | 5 | 0 | 1 | 5 | 1 | 0.039979 | 0 | Reasoning: I'm trying to convert a large library from Scheme to Python
Are there any good strategies for doing this kind of conversion? Specifically cross-paradigm in this case since Python is more OO and Scheme is Functional.
Totally subjective so I'm making it community wiki | 0 | python,scheme,code-translation | 2010-05-23T20:29:00.000 | 0 | 2,893,313 | I would setup a bunch of whiteboards and write out the algorithms from the Scheme code. Then I would implement the algorithms in Python. Then, as @PaulHankin suggests, use the Scheme code as a way to write test cases to test the Python code | 0 | 193 | false | 0 | 1 | Advice on translating code from very unrelated languages (in this case Scheme to Python)? | 2,893,563 |
1 | 3 | 0 | 0 | 4 | 0 | 0 | 0 | for large files or slow connections, copying files may take some time.
using pyinotify, i have been watching for the IN_CREATE event code. but this seems to occur at the start of a file transfer. i need to know when a file is completely copied - it aint much use if it's only half there.
when a file transfer is finished and completed, what inotify event is fired? | 0 | python,inotify,pyinotify | 2010-05-24T06:36:00.000 | 0 | 2,895,187 | Why don't you add a dummy file at the end of the transfer? You can use the IN_CLOSE or IN_CREATE event code on the dummy. The important thing is that the dummy as to be transfered as the last file in the sequence.
I hope it'll help. | 0 | 4,934 | false | 0 | 1 | which inotify event signals the completion of a large file operation? | 22,093,028 |
2 | 2 | 0 | 0 | 2 | 0 | 1.2 | 0 | Is there a way to add tempate string which contains error to mako`s error trace? | 0 | python,mako | 2010-05-25T15:12:00.000 | 0 | 2,905,948 | I don't think you're likely to find such a thing. Like all the other fast python template engines, Mako achieves its speed by compiling your template into python code and then executing it. An exception will divert execution out of your template's code, so by the time one is raised, that template will have no way of displaying it (or doing anything else for that matter).
As an alternative, I suggest putting your template rendering code inside a try block, and rendering any caught exceptions with a separate template used specifically for that purpose. | 0 | 198 | true | 1 | 1 | Better error reporting mako | 2,946,762 |
2 | 2 | 0 | 0 | 2 | 0 | 0 | 0 | Is there a way to add tempate string which contains error to mako`s error trace? | 0 | python,mako | 2010-05-25T15:12:00.000 | 0 | 2,905,948 | I was looking for another error I have and found this. I though it would be nice if you still ever need this, you can achieve it by setting mako.strict_undefined = True. I am using mako-0.6.2 so it may not been possible in the version back in 2010. | 0 | 198 | false | 1 | 1 | Better error reporting mako | 9,271,873 |
2 | 5 | 0 | 1 | 4 | 0 | 0.039979 | 0 | I'm researching how to best extend a C++ application with scripting capability, and I am looking at either Python or JavaScript. User-defined scripts will need the ability to access the application's data model.
Have any of you had experiences with embedding these scripting engines? What are some potential pitfalls? | 0 | javascript,c++,python,scripting,embedding | 2010-05-25T17:47:00.000 | 0 | 2,907,087 | Have a look at angelscript
simple and easy to embed, c/c++ like syntax. free and corss-platform. u can get start in a few hrs. | 0 | 2,816 | false | 0 | 1 | Embedding a scripting engine in C++ | 5,080,151 |
2 | 5 | 0 | 7 | 4 | 0 | 1 | 0 | I'm researching how to best extend a C++ application with scripting capability, and I am looking at either Python or JavaScript. User-defined scripts will need the ability to access the application's data model.
Have any of you had experiences with embedding these scripting engines? What are some potential pitfalls? | 0 | javascript,c++,python,scripting,embedding | 2010-05-25T17:47:00.000 | 0 | 2,907,087 | Lua is also a great candidate for embedding in programs. Its very self contained, and even the native cross-language call system isn't bad.
For JavaScript, your best bet right now is to look at V8 (from Google), which is easy enough to work with. | 0 | 2,816 | false | 0 | 1 | Embedding a scripting engine in C++ | 2,907,217 |
1 | 2 | 0 | 3 | 1 | 0 | 1.2 | 0 | Is there a way to determine an MP3 file's encoded bit depth (ie 8, 16, 24, 32) in Python using the Mutagen library? | 0 | python,mp3,lame,mutagen | 2010-05-26T01:15:00.000 | 0 | 2,909,605 | The transformations done by the MP3 encoding process drop completely the concept of “bit depth”. You can only know the bit depth of the source audio if such information was stored in a tag of the MP3 file. Otherwise, you can take the MP3 data and produce 8-bit, 16-bit or 24-bit audio. | 0 | 1,355 | true | 0 | 1 | Determine MP3 bit depth in Python via Mutagen | 3,113,148 |
1 | 2 | 0 | 2 | 2 | 0 | 0.197375 | 0 | I'm a c# programmer by trade and looking to move my wares over to Ubuntu as a business concern. I have some experience of Python and like it a lot. My question is, as a developer which would be the best language to use when targeting ubuntu Mono c# or python as a commercial concern.
please note that I am not interested in the technical aspects but strictly the commercials of where Ubuntu is heading, I see that there is a lot of work done within using Python and thinking that maybe with the whole Mono issue of who "might" purchase them. | 0 | c#,python,ubuntu,mono | 2010-05-26T10:52:00.000 | 1 | 2,912,216 | I cannot say much about the market for Ubuntu. And since business is your primary concern, the programming language is, as you say yourself, secondary. I would say that in any business, choose the language and tools that solves the business problem most effectively. When release comes do your end users really care?
That said, if you can do it with Mono/C# I would encourage you to do so since you already have C# and .Net experience. But knowing a second language and development environment will only make you stronger. | 0 | 309 | false | 0 | 1 | Which Language to target on Ubuntu? | 2,912,360 |
1 | 2 | 0 | 5 | 0 | 0 | 0.462117 | 0 | Is it possible to get the full path of the file on the user's computer being uploaded to my site?
Using os.path.abspath(fileitem.filename) simply gets me the address of where my script is executing from on my shared hosting server.
FYI: fileitem = form['file'] and form = cgi.FieldStorage() | 0 | python,upload | 2010-05-27T01:53:00.000 | 0 | 2,918,010 | No, that information isn't sent by the user, so it's not available on your end | 0 | 1,903 | false | 1 | 1 | Get Path of Uploaded File using Python | 2,918,021 |
1 | 4 | 0 | 1 | 3 | 0 | 0.049958 | 0 | My student group and I are trying to continue working on a project we worked on this semester over the summer to become a professional, deployable app. We originally did it in Adobe AIR but it seems now that the computers this program will be running on will be very slow, maybe 600mhz and 128-256mb ram so flash just isn't going to cut it. It is basically a health diagnosis application that we will be shipping out to impoverished countries.
Now comes the real question. We are wondering what language to rebuild our application in. It has to have a good gui builder associated with it, like adobe flex/air gui builder or visual studio's gui builder but the application should run on linux primarily, and if it can run on windows thats just a plus. We are all students too without really any outside help so whatever we decide to do this in there must be ample documentation available when we hit problems.
Some things we have considered so far are using python and glade or c# and monodevelop, but again we really are not experts on any of this which is why I am asking for help as I would rather spend the time now choosing the right tools instead of wasting time down the line when we hit a roadblock.
Thanks in advance! | 0 | python,user-interface,open-source,monodevelop,glade | 2010-05-27T04:23:00.000 | 1 | 2,918,445 | To access really low end computers, and if you have no real graphics requirements, you could consider a text mode interface - curses/ncurses for one. | 0 | 1,292 | false | 0 | 1 | Making GUI applications on Linux/Windows. What languages/tools to use? | 2,918,582 |
2 | 3 | 0 | 0 | 2 | 0 | 0 | 0 | Can a python script on my server access the webcam and audio input of a user as easily and as well as a Flash plugin can? | 0 | python,streaming,webcam | 2010-05-28T01:56:00.000 | 0 | 2,926,220 | Server-side web scripts have no access to the client other than through requests. You need to use JavaScript, Java, or Flash to access devices that the browser (and consequently user) allows them to. | 0 | 2,165 | false | 1 | 1 | Python access webcam and audio input | 2,926,268 |
2 | 3 | 0 | 2 | 2 | 0 | 0.132549 | 0 | Can a python script on my server access the webcam and audio input of a user as easily and as well as a Flash plugin can? | 0 | python,streaming,webcam | 2010-05-28T01:56:00.000 | 0 | 2,926,220 | No: the "plugin" you mention runs in the user's browser, your server-side script (Python or otherwise) runs on the server, a completely different proposition. This relates to your other recent question about a server-side script accessing information on your desktop: your client machine tends to be very protected against possibly malicious server-side apps (never enough, but everybody keeps trying to make it more and more protected these days). | 0 | 2,165 | false | 1 | 1 | Python access webcam and audio input | 2,926,270 |
1 | 2 | 0 | 1 | 0 | 0 | 0.099668 | 1 | I am trying to create a directory with news articles collected from an rss feed, meaning that whenever there is a link to an article within the rss feed, I would like for it to be downloaded in a directory with the title of the specific article as the filename as as a text file.
Is that something Python can help me do ?
Thank you for your help :-) | 0 | python,rss | 2010-05-28T08:22:00.000 | 0 | 2,927,543 | Of course. BeautifulSoup, lxml, urllib2, urlgrabber. | 0 | 442 | false | 0 | 1 | Downloading from links in an rss feed | 2,927,551 |
1 | 2 | 0 | 1 | 11 | 1 | 0.099668 | 0 | I'm currently aware of the following Python JIT compilers: Psyco, PyPy and Unladen Swallow.
Basically, I'd like to ask for your personal experiences on the strengths and weaknesses of these compilers - and if there are any others worth looking into.
Thanks in advance,
Az | 0 | python,compiler-construction,project | 2010-05-29T01:49:00.000 | 0 | 2,933,434 | Some other tools you might investigate to speed up python are
Cython, which requires type specification of all variables in the relevant method and then statically compiles the method
Numba, which requires LLVM but is JIT (methods must be decorated with argument types for compilation to occur). | 0 | 5,073 | false | 0 | 1 | Strengths and weaknesses of JIT compilers for Python | 12,135,232 |
1 | 2 | 0 | 1 | 6 | 1 | 0.099668 | 0 | Is there a way to encrypt files (.zip, .doc, .exe, ... any type of file) with Python?
I've looked at a bunch of crypto libraries for Python including pycrypto and ezpycrypto but as far as I see they only offer string encryption. | 0 | python,encryption | 2010-05-30T13:14:00.000 | 0 | 2,938,757 | You can read the complete file into a string, encrypt it, write the encrypted string in a new file. If the file is too large, you can read in chunks.
Every time you .read from a file, you get a string (in Python < 3.0). | 0 | 972 | false | 0 | 1 | File encryption with Python | 2,939,776 |
2 | 3 | 0 | 0 | 0 | 1 | 0 | 0 | This is a weird bug. I know it's something funky going on with my PATH variable, but no idea how to fix it.
If I have a script C:\Test\test.py and I execute it from within IDLE, it works fine. If I open up Command Prompt using Run>>cmd.exe and navigate manually it works fine. But if I use Windows 7's convenient Right Click on folder >> Command Prompt Here then type test.py it fails with import errors.
I also cannot just type "python" to reach a python shell session if I use the latter method above.
Any ideas?
Edit: printing the python path for the command prompt that works yields the correct paths. Printing it on the non-working "Command prompt here" yields: Environment variable python not defined". | 0 | python,windows-7,path | 2010-05-31T11:03:00.000 | 1 | 2,943,071 | You can check the currently present enviroment variables with the "set" command on the command line. For python to work you need at least PYTHONPATH pointing to your python libs and the path to python.exe should be included in your PATH variable. | 0 | 2,823 | false | 0 | 1 | Python doesn't work properly when I execute a script after using Right Click >> Command Prompt Here | 2,943,171 |
2 | 3 | 0 | 1 | 0 | 1 | 0.066568 | 0 | This is a weird bug. I know it's something funky going on with my PATH variable, but no idea how to fix it.
If I have a script C:\Test\test.py and I execute it from within IDLE, it works fine. If I open up Command Prompt using Run>>cmd.exe and navigate manually it works fine. But if I use Windows 7's convenient Right Click on folder >> Command Prompt Here then type test.py it fails with import errors.
I also cannot just type "python" to reach a python shell session if I use the latter method above.
Any ideas?
Edit: printing the python path for the command prompt that works yields the correct paths. Printing it on the non-working "Command prompt here" yields: Environment variable python not defined". | 0 | python,windows-7,path | 2010-05-31T11:03:00.000 | 1 | 2,943,071 | I don't use Windows much, but maybe when you open Right Click -> Command Prompt, the PATH is different from navigate manually. First try to print your PATH (oh I have no ideal how to do this) and see if it different in 2 situation. | 0 | 2,823 | false | 0 | 1 | Python doesn't work properly when I execute a script after using Right Click >> Command Prompt Here | 2,943,111 |
1 | 2 | 0 | 2 | 1 | 0 | 0.197375 | 0 | Starting a Perl script with alarm(3600) will make the script abort if it is still running after one hour (3600 seconds).
Assume I want to set an upper bound on the running time of a Python script, what is the easiest way to achieve that? | 0 | python | 2010-06-01T09:09:00.000 | 1 | 2,948,455 | Just for your information: this is much self-descriptive to use multiplication when you set up timers, for example alarm(24 * 60 * 60) for 24 hours, instead of alarm(86400) for the same period. Hope this will help keep your code clean and easy-maintainable :) | 0 | 362 | false | 0 | 1 | Equivalent of alarm(3600) in Python | 2,949,014 |
1 | 1 | 0 | 2 | 2 | 0 | 1.2 | 0 | I am developing a small testing website using Django 1.2 in Aptana Studio build 2.0.4.1268158907. I have a Django project that I test by running the command "runserver 8001" on my project. This command runs the project on a small server that comes with Django.
However the problem arises that every time I run this command Aptana opens two instances of the process "python.exe". Upon terminating the command only one of these instances is ended. The other process continues to run and use memory. My server is not online, and the process doesn't seem to do anything that I can find. This happens every time i run the runserver command on my project and therefore more and more python.exe instances will open up through my development period.
Any help discovering either the purpose of this extra python.exe or a way to prevent it from opening would be much appreciated. | 0 | python,django,aptana | 2010-06-01T20:08:00.000 | 1 | 2,952,957 | You should try adding --noreload to the runserver argument | 0 | 509 | true | 1 | 1 | Aptana Studio is opening but not ever closing a python.exe process | 2,952,983 |
1 | 2 | 0 | 4 | 1 | 0 | 1.2 | 0 | Looking to use FastLZ in Python, or something similar. Tried Google and didn't find anything. Wondering if there is another algorithm with similar performance available in Python? | 0 | python,compression | 2010-06-02T02:50:00.000 | 0 | 2,954,696 | What about using ctypes to call directly into fastlz.so (or .dll as the case may be)? It seems to have only 3 entry points, so wrapping them in ctypes should not be hard. Yes, SWIG or a custom C API wrapper should be almost as trivial, but ctypes lets you start experimenting right now even if you don't have a compiler (as long as you can get a working DLL/so of FastLZ for your platform)... hard to beat!-) | 0 | 565 | true | 0 | 1 | Is there a python wrapper for a FastLZ implementation | 2,954,788 |
1 | 3 | 0 | 1 | 1 | 1 | 1.2 | 0 | I have a python script and am wondering is there any way that I can ensure that the script run's continuously on a remote computer? Like for example, if the script crashes for whatever reason, is there a way to start it up automatically instead of having to remote desktop. Are there any other factors I have to be aware of? The script will be running on a window's machine. | 0 | python | 2010-06-02T12:21:00.000 | 1 | 2,957,588 | Many ways - In the case of windows, even a simple looping batch file would probably do - just have it start the script in a loop (whenever it crashes it would return to the shell and be restarted). | 0 | 1,086 | true | 0 | 1 | running a python script on a remote computer | 2,957,649 |
1 | 8 | 0 | 1 | 12 | 0 | 0.024995 | 0 | Can anyone point me to some documentation on how to write scripts in Python (or Perl or any other Linux friendly script language) that generate C++ code from XML or py files from the command line. I'd like to be able to write up some xml files and then run a shell command that reads these files and generates .h files with fully inlined functions, e.g. streaming operators, constructors, etc. | 0 | c++,python,code-generation | 2010-06-03T13:57:00.000 | 1 | 2,966,618 | A few years ago I worked on a project to simplify interprocess shared memory management for large scale simulation systems. We used a related approach where the layout of data in shared memory was defined in XML files and a code generator, written in python, read the XML and spit out a set of header files defining structures and associated functions/operators/etc to match the XML description. At the time, I looked at several templating engines and, to my surprise, found it was easier and very straight-forward to just do it "by hand".
As you read the XML, just populate a set of data structures that match your code. Header file objects contain classes and classes contain variables (which may be of other class types). Give each object a printSelf() method that iterates over its contents and calls printSelf() for each object it contains.
It seems a little daunting at first but once you get started, it's pretty straight-forward. Oh, and one tip that helps with the generated code, add an indentation argument to printSelf() and increase it at each level. It makes the generated code much easier to read. | 0 | 23,299 | false | 0 | 1 | C++ code generation with Python | 2,966,999 |
1 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | I'm interested in reproducing a particular python script.
I have a friend who was accessing an ldap database, without authentication. There was a particular field of interest, we'll call it nin (an integer) for reference, and this field wasn't accessible without proper authentication. However, my friend managed to access this field through some sort of binary search (rather than just looping through integers) on the data; he would check the first digit, check if it was greater or less than the starting value, he would augment that until it returned a true value indicating existence, adding digits and continuing checking until he found the exact value of the integer nin.
Any ideas on how he went about this? I've access to a similarly set up database. | 0 | python,ldap | 2010-06-03T17:00:00.000 | 0 | 2,968,127 | Your best bet would be to get authorization to access that field. You are circumventing the security of the database otherwise. | 0 | 231 | false | 0 | 1 | Binary search of unaccesible data field in ldap from python | 2,968,258 |
2 | 5 | 0 | 1 | 4 | 0 | 0.039979 | 0 | i wonder if there is a php equivalent to jython so you can use java classes with php?
thanks | 0 | java,php,python,jython | 2010-06-03T17:35:00.000 | 0 | 2,968,381 | Well: Java Server Pages (JSP) are "equivalent" to PHP, but using java classes.
It's "equivalent" in that it's HTML with embedded java code, but not at all compatible to PHP syntax. | 0 | 494 | false | 1 | 1 | php equivalent to jython? | 2,968,495 |
2 | 5 | 0 | 1 | 4 | 0 | 0.039979 | 0 | i wonder if there is a php equivalent to jython so you can use java classes with php?
thanks | 0 | java,php,python,jython | 2010-06-03T17:35:00.000 | 0 | 2,968,381 | I just googled php jvm and got a bunch of hits. Never tried any of them. | 0 | 494 | false | 1 | 1 | php equivalent to jython? | 2,968,418 |
1 | 2 | 0 | 0 | 6 | 1 | 1.2 | 0 | I've finally figured out how to create a Python egg and gotten it to work. Now... what do I do with it? How do I use it? How do I ensure that everything was correctly included? (Simple steps please... not just redirection to another site. I've googled, but it's confusing me, and I was hoping someone could explain it in a couple of simple bullet points or sentences.)
Edit:
I asked this question a couple of weeks ago, and I'm clarifying now in the hope of getting clearer answers... basically, I have an egg, I want to take it to another machine and be able to use it and import modules from it from my (other, unrelated) code. How do I do this? | 0 | python,distribution,egg | 2010-06-03T18:40:00.000 | 0 | 2,968,809 | What I ended up doing was:
Ran PYTHONPATH=fullPathOfMyEgg in command line
Was then able to do import someModuleInMyEgg from my Python code
I'm not sure if this is the most standard or accepted way to do it, but it worked. If anyone has any comments or other methods, please feel free to add... | 0 | 612 | true | 0 | 1 | I created a Python egg; now what? | 3,063,352 |
2 | 12 | 0 | 37 | 145 | 0 | 1 | 0 | I have Python script bgservice.py and I want it to run all the time, because it is part of the web service I build. How can I make it run continuously even after I logout SSH? | 0 | python,service,cron | 2010-06-04T15:39:00.000 | 1 | 2,975,624 | If you've already started the process, and don't want to kill it and restart under nohup, you can send it to the background, then disown it.
Ctrl+Z (suspend the process)
bg (restart the process in the background
disown %1 (assuming this is job #1, use jobs to determine) | 0 | 252,941 | false | 0 | 1 | How to run a script in the background even after I logout SSH? | 2,975,852 |
2 | 12 | 0 | 7 | 145 | 0 | 1 | 0 | I have Python script bgservice.py and I want it to run all the time, because it is part of the web service I build. How can I make it run continuously even after I logout SSH? | 0 | python,service,cron | 2010-06-04T15:39:00.000 | 1 | 2,975,624 | Alternate answer: tmux
ssh into the remote machine
type tmux into cmd
start the process you want inside the tmux e.g. python3 main.py
leaving the tmux session by Ctrl+b then d
It is now safe to exit the remote machine. When you come back use tmux attach to re-enter tmux session.
If you want to start multiple sessions, name each session using Ctrl+b then $. then type your session name.
to list all session use tmux list-sessions
to attach a running session use tmux attach-session -t <session-name>. | 0 | 252,941 | false | 0 | 1 | How to run a script in the background even after I logout SSH? | 69,754,988 |
6 | 6 | 0 | 5 | 1 | 0 | 0.16514 | 0 | if i want to script a mini-application (in the Terminal) in mac and windows, which one is preferred: ruby or python?
or is there no major difference just a matter of taste?
cause i know python definetely is a good scripting language.
thanks | 0 | python,ruby | 2010-06-05T01:53:00.000 | 1 | 2,978,801 | Personally, I find the documentation for Python is much better than that for Ruby. The Docs for Ruby are full of cryptic examples that are terse, short, and just not very helpful.
On the other hand, docs for Python exist everywhere, but more importantly, in a useful, helpful form. | 0 | 551 | false | 0 | 1 | ruby or python more suitable for scripting in all OSes? | 2,979,717 |
6 | 6 | 0 | 2 | 1 | 0 | 0.066568 | 0 | if i want to script a mini-application (in the Terminal) in mac and windows, which one is preferred: ruby or python?
or is there no major difference just a matter of taste?
cause i know python definetely is a good scripting language.
thanks | 0 | python,ruby | 2010-06-05T01:53:00.000 | 1 | 2,978,801 | I believe python and ruby (since at least OS X 10.4) came pre-installed on Mac, that is a convenience.
There are easy installers for Windows. On Linux of course your mileage may vary.
As much as i like python myself, don't think one is better than the other for your purpose. | 0 | 551 | false | 0 | 1 | ruby or python more suitable for scripting in all OSes? | 2,978,961 |
6 | 6 | 0 | 2 | 1 | 0 | 0.066568 | 0 | if i want to script a mini-application (in the Terminal) in mac and windows, which one is preferred: ruby or python?
or is there no major difference just a matter of taste?
cause i know python definetely is a good scripting language.
thanks | 0 | python,ruby | 2010-06-05T01:53:00.000 | 1 | 2,978,801 | Python is perhaps a little more common, and arguably more mature, so on that basis alone, it may be worth choosing Python.
That said, both are available by default on Mac OS X, and neither are available on Windows by default, so in this case it really does not matter. | 0 | 551 | false | 0 | 1 | ruby or python more suitable for scripting in all OSes? | 2,979,070 |
6 | 6 | 0 | 2 | 1 | 0 | 0.066568 | 0 | if i want to script a mini-application (in the Terminal) in mac and windows, which one is preferred: ruby or python?
or is there no major difference just a matter of taste?
cause i know python definetely is a good scripting language.
thanks | 0 | python,ruby | 2010-06-05T01:53:00.000 | 1 | 2,978,801 | I would suggest to go for Python over Ruby on Windows unless you are willing to port some gems as a few (no I cannot say what percentage) of the gems use unix/mac specific stuff (example from ENV[OSTYPE] to wget to unix processes) that I have seen break on windows. | 0 | 551 | false | 0 | 1 | ruby or python more suitable for scripting in all OSes? | 2,979,691 |
6 | 6 | 0 | 0 | 1 | 0 | 0 | 0 | if i want to script a mini-application (in the Terminal) in mac and windows, which one is preferred: ruby or python?
or is there no major difference just a matter of taste?
cause i know python definetely is a good scripting language.
thanks | 0 | python,ruby | 2010-06-05T01:53:00.000 | 1 | 2,978,801 | Both are excelent options, you won't go wrong no matter which one you chose. You should check out the availability of libraries for the task at hand and also how helpful the community is. The Python community is humongous and seems friendlier to me. Rubists seem to have some anger management issues. | 0 | 551 | false | 0 | 1 | ruby or python more suitable for scripting in all OSes? | 3,028,950 |
6 | 6 | 0 | 5 | 1 | 0 | 1.2 | 0 | if i want to script a mini-application (in the Terminal) in mac and windows, which one is preferred: ruby or python?
or is there no major difference just a matter of taste?
cause i know python definetely is a good scripting language.
thanks | 0 | python,ruby | 2010-06-05T01:53:00.000 | 1 | 2,978,801 | Matter of taste, really. They each have a pretty good set of libraries and are cross-platform, so it'll be a matter of which one you prefer to code in. | 0 | 551 | true | 0 | 1 | ruby or python more suitable for scripting in all OSes? | 2,978,809 |
5 | 6 | 0 | 4 | 10 | 0 | 0.132549 | 0 | Are there any real differences between them?
I want to program in java and python. And of corse be a normal user: internet, etc
Which one will give me less headaches/more satisfaction ?
And which is better for a server machine ?
Thank you | 0 | java,python,ubuntu,debian,operating-system | 2010-06-06T18:44:00.000 | 1 | 2,985,426 | Both use Debian packages and Ubuntu is based on Debian but is more user friendly. Everything yo can do on one you can do on the other. I'd recommend Ubuntu if your new to linux on a Desktop. Though when it comes to servers I'd recommend Debian as it has less stuff "taken out" basically. | 0 | 20,812 | false | 0 | 1 | Which os is better for development : Debian or Ubuntu? | 2,985,450 |
5 | 6 | 0 | 1 | 10 | 0 | 0.033321 | 0 | Are there any real differences between them?
I want to program in java and python. And of corse be a normal user: internet, etc
Which one will give me less headaches/more satisfaction ?
And which is better for a server machine ?
Thank you | 0 | java,python,ubuntu,debian,operating-system | 2010-06-06T18:44:00.000 | 1 | 2,985,426 | In Ubuntu it is a bit easier to install packages for Java development, but it doesn't really matter that much. Remember that Ubuntu is based on Debian, so it works the same. Ubuntu just adds more user-friendly GUI's. | 0 | 20,812 | false | 0 | 1 | Which os is better for development : Debian or Ubuntu? | 2,985,456 |
5 | 6 | 0 | 2 | 10 | 0 | 0.066568 | 0 | Are there any real differences between them?
I want to program in java and python. And of corse be a normal user: internet, etc
Which one will give me less headaches/more satisfaction ?
And which is better for a server machine ?
Thank you | 0 | java,python,ubuntu,debian,operating-system | 2010-06-06T18:44:00.000 | 1 | 2,985,426 | Ubuntu is the more user-friendly of the two (I think Ubuntu is actually one of the most newbie-friendly Linux distros), so if you are new to Linux, Ubuntu is the way to go. Otherwise, the packages are mostly the same except for branding, so it's pretty much your choice. | 0 | 20,812 | false | 0 | 1 | Which os is better for development : Debian or Ubuntu? | 2,985,463 |
5 | 6 | 0 | 1 | 10 | 0 | 0.033321 | 0 | Are there any real differences between them?
I want to program in java and python. And of corse be a normal user: internet, etc
Which one will give me less headaches/more satisfaction ?
And which is better for a server machine ?
Thank you | 0 | java,python,ubuntu,debian,operating-system | 2010-06-06T18:44:00.000 | 1 | 2,985,426 | Neither is better. They both support the same tools and libraries. They are both linux. Anything and everything you can do on one you can do on the other. | 0 | 20,812 | false | 0 | 1 | Which os is better for development : Debian or Ubuntu? | 2,985,472 |
5 | 6 | 0 | 2 | 10 | 0 | 0.066568 | 0 | Are there any real differences between them?
I want to program in java and python. And of corse be a normal user: internet, etc
Which one will give me less headaches/more satisfaction ?
And which is better for a server machine ?
Thank you | 0 | java,python,ubuntu,debian,operating-system | 2010-06-06T18:44:00.000 | 1 | 2,985,426 | java and python would most likely run the same on both.
With Ubuntu you get additional space of support and active community, and perhaps larger user base.
So if and when you face a particular problem, chances are with Ubuntu, the solution will appear faster.
(although, whatever works on this should work on the other as well in theory) | 0 | 20,812 | false | 0 | 1 | Which os is better for development : Debian or Ubuntu? | 2,985,442 |
1 | 4 | 0 | 1 | 5 | 1 | 0.049958 | 0 | I'm newish to the python ecosystem, and have a question about module editing.
I use a bunch of third-party modules, distributed on PyPi. Coming from a C and Java background, I love the ease of easy_install <whatever>. This is a new, wonderful world, but the model breaks down when I want to edit the newly installed module for two reasons:
The egg files may be stored in a folder or archive somewhere crazy on the file system.
Using an egg seems to preclude using the version control system of the originating project, just as using a debian package precludes development from an originating VCS repository.
What is the best practice for installing modules from an arbitrary VCS repository? I want to be able to continue to import foomodule in other scripts. And if I modify the module's source code, will I need to perform any additional commands? | 0 | python,version-control,module,easy-install | 2010-06-06T23:32:00.000 | 1 | 2,986,357 | Packages installed by easy_install tend to come from snapshots of the developer's version control, generally made when the developer releases an official version. You're therefore going to have to choose between convenient automatic downloads via easy_install and up-to-the-minute code updates via version control. If you pick the latter, you can build and install most packages seen in the python package index directly from a version control checkout by running python setup.py install.
If you don't like the default installation directory, you can install to a custom location instead, and export a PYTHONPATH environment variable whose value is the path of the installed package's parent folder. | 0 | 1,655 | false | 0 | 1 | Best practice for installing python modules from an arbitrary VCS repository | 2,986,445 |
3 | 5 | 0 | 0 | 23 | 0 | 0 | 0 | How do I get the ports that a process is listening on using python? The pid of the process is known. | 0 | python,linux,sockets,port | 2010-06-07T05:04:00.000 | 1 | 2,987,168 | One thing that wasn't mentioned. Most port applications in python take a command line argument. You can parse /proc/pid/cmdline and parse out the port number. This avoids the large overhead of using ss or netstat on servers with a ton of connections. | 0 | 21,117 | false | 0 | 1 | How to obtain ports that a process in listening on? | 42,511,544 |
3 | 5 | 0 | 1 | 23 | 0 | 0.039979 | 0 | How do I get the ports that a process is listening on using python? The pid of the process is known. | 0 | python,linux,sockets,port | 2010-06-07T05:04:00.000 | 1 | 2,987,168 | You can use netstat -lnp, last column will contain pid and process name. In Python you can parse output of this command. | 0 | 21,117 | false | 0 | 1 | How to obtain ports that a process in listening on? | 2,987,231 |
3 | 5 | 0 | 4 | 23 | 0 | 0.158649 | 0 | How do I get the ports that a process is listening on using python? The pid of the process is known. | 0 | python,linux,sockets,port | 2010-06-07T05:04:00.000 | 1 | 2,987,168 | If you don't want to parse the output of a program like netstat or lsof, you can grovel through the /proc filesystem and try to find documentation on the files within. /proc/<pid>/net/tcp might be especially interesting to you. Of course, the format of those files might change between kernel releases, so parsing command output is generally considered more reliable. | 0 | 21,117 | false | 0 | 1 | How to obtain ports that a process in listening on? | 2,987,379 |
1 | 5 | 0 | 2 | 26 | 1 | 0.07983 | 0 | What are the options for achieving parallelism in Python? I want to perform a bunch of CPU bound calculations over some very large rasters, and would like to parallelise them. Coming from a C background, I am familiar with three approaches to parallelism:
Message passing processes, possibly distributed across a cluster, e.g. MPI.
Explicit shared memory parallelism, either using pthreads or fork(), pipe(), et. al
Implicit shared memory parallelism, using OpenMP.
Deciding on an approach to use is an exercise in trade-offs.
In Python, what approaches are available and what are their characteristics? Is there a clusterable MPI clone? What are the preferred ways of achieving shared memory parallelism? I have heard reference to problems with the GIL, as well as references to tasklets.
In short, what do I need to know about the different parallelization strategies in Python before choosing between them? | 0 | python,multithreading,parallel-processing,message-passing | 2010-06-07T08:22:00.000 | 0 | 2,987,980 | Depending on how much data you need to process and how many CPUs/machines you intend to use, it is in some cases better to write a part of it in C (or Java/C# if you want to use jython/IronPython)
The speedup you can get from that might do more for your performance than running things in parallel on 8 CPUs. | 0 | 14,722 | false | 0 | 1 | Parallelism in Python | 2,988,386 |
1 | 2 | 0 | 2 | 6 | 1 | 0.197375 | 0 | I'm writing python package/module and would like the logging messages mention what module/class/function they come from. I.e. if I run this code:
import mymodule.utils.worker as worker
w = worker.Worker()
w.run()
I'd like to logging messages looks like this:
2010-06-07 15:15:29 INFO mymodule.utils.worker.Worker.run <pid/threadid>: Hello from worker
How can I accomplish this?
Thanks. | 0 | python,logging | 2010-06-07T12:24:00.000 | 0 | 2,989,398 | Here is my solution that came out of this discussion. Thanks to everyone for suggestions.
Usage:
>>> import logging
>>> logging.basicConfig(level=logging.DEBUG)
>>> from hierlogger import hierlogger as logger
>>> def main():
... logger().debug("test")
...
>>> main()
DEBUG:main:test
By default it will name logger as ... You can also control the depth by providing parameter:
3 - module.class.method default
2 - module.class
1 - module only
Logger instances are also cached to prevent calculating logger name on each call.
I hope someone will enjoy it.
The code:
import logging
import inspect
class NullHandler(logging.Handler):
def emit(self, record): pass
def hierlogger(level=3):
callerFrame = inspect.stack()[1]
caller = callerFrame[0]
lname = '__heirlogger'+str(level)+'__'
if lname not in caller.f_locals:
loggerName = str()
if level >= 1:
try:
loggerName += inspect.getmodule(inspect.stack()[1][0]).__name__
except: pass
if 'self' in caller.f_locals and (level >= 2):
loggerName += ('.' if len(loggerName) > 0 else '') +
caller.f_locals['self'].__class__.__name__
if callerFrame[3] != '' and level >= 3:
loggerName += ('.' if len(loggerName) > 0 else '') + callerFrame[3]
caller.f_locals[lname] = logging.getLogger(loggerName)
caller.f_locals[lname].addHandler(NullHandler())
return caller.f_locals[lname] | 0 | 3,330 | false | 0 | 1 | logger chain in python | 3,060,995 |
9 | 10 | 0 | 2 | 6 | 0 | 0.039979 | 0 | I know it is a kind of broad question but any answer are appreciated. | 0 | c#,java,python | 2010-06-07T17:07:00.000 | 0 | 2,991,554 | Java and C# are statically typed languages, while Python is a dynamically typed language. That's a huge difference.
The syntax of Java and C# is similar (but I would not call it "almost identical" as Justin Niessner says). | 0 | 29,161 | false | 0 | 1 | How Similar are Java, C#, and Python? | 2,991,586 |
9 | 10 | 0 | 7 | 6 | 0 | 1 | 0 | I know it is a kind of broad question but any answer are appreciated. | 0 | c#,java,python | 2010-06-07T17:07:00.000 | 0 | 2,991,554 | C# and Java have almost identical syntax and very similar libraries. There are differences that you have to be aware of (Type Erasure in Java, for example).
Python is a completely different animal. It is a dynamic language (where the other two aren't). Python winds up being closer in style to something like Ruby. | 0 | 29,161 | false | 0 | 1 | How Similar are Java, C#, and Python? | 2,991,562 |
9 | 10 | 0 | 11 | 6 | 0 | 1 | 0 | I know it is a kind of broad question but any answer are appreciated. | 0 | c#,java,python | 2010-06-07T17:07:00.000 | 0 | 2,991,554 | Python is a dynamic language where Java and C# are really not. It is totally different than the other two. There are ways to accomplishing things in Python that do not translate well to the others and vice versa.
Java and C# look the same, but they have differences between the two under the sheets. Being an expert in one, does not make you an expert in the other by any stretch of the imagination. The syntax is similar and libraries are too, so it would be easier to get up to speed in one or the other, but there are subtleties that can trip you up. | 0 | 29,161 | false | 0 | 1 | How Similar are Java, C#, and Python? | 2,991,567 |
9 | 10 | 0 | -2 | 6 | 0 | -0.039979 | 0 | I know it is a kind of broad question but any answer are appreciated. | 0 | c#,java,python | 2010-06-07T17:07:00.000 | 0 | 2,991,554 | They are not similar at ALL. They all take widely different approaches to OOP, syntax, and static/dynamic typing. | 0 | 29,161 | false | 0 | 1 | How Similar are Java, C#, and Python? | 2,991,564 |
9 | 10 | 0 | 1 | 6 | 0 | 0.019997 | 0 | I know it is a kind of broad question but any answer are appreciated. | 0 | c#,java,python | 2010-06-07T17:07:00.000 | 0 | 2,991,554 | Java and c# are pretty similar in terms of syntax and are mostly strongly typed (C# is getting more dynamic with every version), Python is a dynamic language | 0 | 29,161 | false | 0 | 1 | How Similar are Java, C#, and Python? | 2,991,569 |
9 | 10 | 0 | 1 | 6 | 0 | 0.019997 | 0 | I know it is a kind of broad question but any answer are appreciated. | 0 | c#,java,python | 2010-06-07T17:07:00.000 | 0 | 2,991,554 | Java and C# are very similar and are syntactically similar to C/C++. They also use braces to mark code blocks.
Python is completely different. Although imperative like Java and C#, Python uses indentation to define blocks of code.
Java and C# are also compiled languages, whereas Python is interpreted and dynamic.
Python, Ruby, and Groovy are somewhat similar languages. | 0 | 29,161 | false | 0 | 1 | How Similar are Java, C#, and Python? | 2,991,581 |
9 | 10 | 0 | 1 | 6 | 0 | 0.019997 | 0 | I know it is a kind of broad question but any answer are appreciated. | 0 | c#,java,python | 2010-06-07T17:07:00.000 | 0 | 2,991,554 | C# and Java are the two languages you listed that are most similar. Python has a very different syntax, and uses a slightly different programming model. Both C# and Java are Object Oriented languages at their core, with increasing nods to Dynamic Typing. Python began as a Dynamically Typed scripting language and has been picking up more and more Object Oriented features over the years.
The C# class library (.NET Framework) is theoretically multi-platform, though it's heavily weighted towards the Windows platform, and any other OS compatibility is largely an afterthought. The .NET framework currently has two "official" frameworks for building windowed applications (Windows Forms, and WPF) and two "official" frameworks for building web applications (ASP.NET, and ASP.NET MVC). Windows Forms is similar to Java Swing, but the other four frameworks are very different from much of what is found in the Java or Python worlds. There are many language features in C# that are different or lacking in Java, such as Delegates.
The Java class library is pretty solidly multi-platform. It's officially supported desktop and web frameworks (Swing and J2EE) are generally regarded as slow, and difficult to use. However, there is a very lively open source community which has built several competing frameworks that are very powerful and versatile. Java as a language is very slow to introduce new language features, though it is runtime-compatible with several other languages that run on the Java platform (Groovy, Jython, Scala, etc..). Java is the language which has has the most run-time optimizations put into it, so an application written in Java is almost certainly going to be faster than an application written in C# or Python.
Python is an interpreted language (in general), and is pretty solidly multi-platform. Python has no "official" desktop or web frameworks, though desktop applications can be written using GTK or Qt support, both of which are multi-platform. Django has become a de-facto standard for Python web development, and is regarded as a very powerful and expressive framework. Python is at this point fully Object Oriented, and is notable for it's powerful tools for working with collections/arrays/lists. As an interpreted language, Python will be significantly slower than either C# or Java. | 0 | 29,161 | false | 0 | 1 | How Similar are Java, C#, and Python? | 2,992,318 |
9 | 10 | 0 | 1 | 6 | 0 | 0.019997 | 0 | I know it is a kind of broad question but any answer are appreciated. | 0 | c#,java,python | 2010-06-07T17:07:00.000 | 0 | 2,991,554 | C# and Java are easy to move between, although I don't know many people who are experts in both. C#'s syntax is based off of Java, so they read very, very similarly. They both run cross-platform; Java on the JVM, C# on .NET or Mono. They're both OOP, and widely used for web development. I'd use whichever the team was more familiar with.
Python's off to the side there. It's also used frequently as a scripting language. It can use classes and object orientation, but isn't forced to. It's not as well supported for web work. I'd use this for a different set of tasks than C#/Java. | 0 | 29,161 | false | 0 | 1 | How Similar are Java, C#, and Python? | 2,991,604 |
9 | 10 | 0 | -1 | 6 | 0 | -0.019997 | 0 | I know it is a kind of broad question but any answer are appreciated. | 0 | c#,java,python | 2010-06-07T17:07:00.000 | 0 | 2,991,554 | Python was made to be simpler, more readable, flexible and object oriented than what existed before - i.e. Java, Perl etc. It's actually closer to Java than it is to Ruby. Ruby is more like Smalltalk. Think of Python as Java without the stuff that mostly gets in your way, makes things awkward to do, slows you down or clutters the essence of your logic. So no semi-colons, curly braces for scoping. No static variable declaration or variables at all really they're identifiers that point to objects instead.
There's also a standard style guide for Python unlike other languages. Indentation is used to indicate scope and inconsistent indentation is a syntax error.
It also includes some often used things built into the language: lists, dictionaries, sets, generators etc.
Java is nice for those familiar with C / C++ syntax and are set in their ways, like that syntax and find it readable. Ruby and Python are for those that preferred Pascal or Smalltalk to C, like Lisp etc. | 0 | 29,161 | false | 0 | 1 | How Similar are Java, C#, and Python? | 2,991,639 |
1 | 2 | 0 | 3 | 7 | 0 | 1.2 | 0 | I am passing some weakrefs from Python into C++ class, but C++ destructors are actively trying to access the ref when the real object is already dead, obviously it crashes...
Is there any Python C/API approach to find out if Python reference is still alive or any other known workaround for this ?
Thanks | 0 | c++,python,reference,weak | 2010-06-07T21:43:00.000 | 0 | 2,993,393 | If you call PyWeakref_GetObject on the weak reference it should return either Py_None or NULL, I forget which. But you should check if it's returning one of those and that will tell you that the referenced object is no longer alive. | 0 | 1,004 | true | 0 | 1 | Python - how to check if weak reference is still available | 2,993,422 |
3 | 8 | 0 | 1 | 7 | 1 | 0.024995 | 0 | I'm just starting out learning python with GEdit plus various plugins as my IDE.
Visual Studio/F# has a feature which permits the highlighting on a piece of text in the code window which then, on a keypress, gets executed in the F# console.
Is there a similar facility/plugin which would enable this sort of behaviour for GEdit/Python? I do have various execution type plugins (Run In Python,Better Python Console) but they don't give me this particular behaviour - or at least I'm not sure how to configure them to give me this. I find it useful because in learning python, I have some test code I want to execute particular individual lines or small segments of code (rather then a complete file) to try and understand what they are doing (and the copy/paste can get a bit tiresome)
... or perhaps there is a better way to do code exploration?
Many thx
Simon | 0 | python,plugins,gedit | 2010-06-08T05:51:00.000 | 0 | 2,995,041 | What I do is keep a file called python_temp.py. I have a shortcut to it in my dock. I use it as a scratch pad. Whenever I want to quickly run some code, I copy the code, click the shortcut in the doc, paste in the text and hit f5 to run. Quick, easy, simple, flexible. | 0 | 23,890 | false | 0 | 1 | GEdit/Python execution plugin? | 2,995,380 |
3 | 8 | 0 | 1 | 7 | 1 | 0.024995 | 0 | I'm just starting out learning python with GEdit plus various plugins as my IDE.
Visual Studio/F# has a feature which permits the highlighting on a piece of text in the code window which then, on a keypress, gets executed in the F# console.
Is there a similar facility/plugin which would enable this sort of behaviour for GEdit/Python? I do have various execution type plugins (Run In Python,Better Python Console) but they don't give me this particular behaviour - or at least I'm not sure how to configure them to give me this. I find it useful because in learning python, I have some test code I want to execute particular individual lines or small segments of code (rather then a complete file) to try and understand what they are doing (and the copy/paste can get a bit tiresome)
... or perhaps there is a better way to do code exploration?
Many thx
Simon | 0 | python,plugins,gedit | 2010-06-08T05:51:00.000 | 0 | 2,995,041 | The closest to a decent IDE...
Install gedit-developer-plugins (through synaptic || apt-get) and don't forget to enable (what you need) from gEdit's plugins (Edit->Preferences [tab] plugins) and happy coding | 0 | 23,890 | false | 0 | 1 | GEdit/Python execution plugin? | 18,914,523 |
3 | 8 | 0 | 1 | 7 | 1 | 0.024995 | 0 | I'm just starting out learning python with GEdit plus various plugins as my IDE.
Visual Studio/F# has a feature which permits the highlighting on a piece of text in the code window which then, on a keypress, gets executed in the F# console.
Is there a similar facility/plugin which would enable this sort of behaviour for GEdit/Python? I do have various execution type plugins (Run In Python,Better Python Console) but they don't give me this particular behaviour - or at least I'm not sure how to configure them to give me this. I find it useful because in learning python, I have some test code I want to execute particular individual lines or small segments of code (rather then a complete file) to try and understand what they are doing (and the copy/paste can get a bit tiresome)
... or perhaps there is a better way to do code exploration?
Many thx
Simon | 0 | python,plugins,gedit | 2010-06-08T05:51:00.000 | 0 | 2,995,041 | I installed iPython console in gedit and do most of my simple scripting in it, but gedit is a very simple editor, so it'll not have some advance feature like an IDE
But if you want code exploring, or auto completion, I recommend a real IDE like Eclipse.
If you just want a editor, KomodoEdit is fine. | 0 | 23,890 | false | 0 | 1 | GEdit/Python execution plugin? | 2,995,332 |
2 | 2 | 0 | 31 | 51 | 1 | 1 | 0 | Think the title summarizes the question :-) | 0 | python,scripting,module | 2010-06-08T09:27:00.000 | 0 | 2,996,110 | Any Python module may be executed as a script. The only significant difference is that when imported as a module the filename is used as the basis for the module name whereas if you execute it as a script the module is named __main__.
This distinction makes it possible to have different behaviour when imported by enclosing script specific code in a block guarded by if __name__=="__main__". This has been known to cause confusion when a user attempts to import the main module under its own name rather than importing __main__.
A minor difference between scripts and modules is that when you import a module the system will attempt to use an existing .pyc file (provided it exists and is up to date and for that version of Python) and if it has to compile from a .py file it will attempt to save a .pyc file. When you run a .py file as script it does not attempt to load a previously compiled module, nor will it attempt to save the compiled code. For this reason it may be worth keeping scripts small to minimise startup time. | 0 | 32,140 | false | 0 | 1 | What is the difference between a module and a script in Python? | 2,997,044 |
2 | 2 | 0 | 62 | 51 | 1 | 1.2 | 0 | Think the title summarizes the question :-) | 0 | python,scripting,module | 2010-06-08T09:27:00.000 | 0 | 2,996,110 | A script is generally a directly executable piece of code, run by itself. A module is generally a library, imported by other pieces of code.
Note that there's no internal distinction -- both are executable and importable, although library code often won't do anything (or will just run its unit tests) when executed directly and importing code designed to be a script will cause it to execute, hence the common if __name__ == "__main__" test. | 0 | 32,140 | true | 0 | 1 | What is the difference between a module and a script in Python? | 2,996,170 |
4 | 5 | 0 | 3 | 1 | 1 | 0.119427 | 0 | in my program i have a method which requires about 4 files to be open each time it is called,as i require to take some data.all this data from the file i have been storing in list for manupalation.
I approximatily need to call this method about 10,000 times.which is making my program very slow?
any method for handling this files in a better ways and is storing the whole data in list time consuming what is better alternatives for list?
I can give some code,but my previous question was closed as that only confused everyone as it is a part of big program and need to be explained completely to understand,so i am not giving any code,please suggest ways thinking this as a general question...
thanks in advance | 0 | python,optimization | 2010-06-09T14:28:00.000 | 0 | 3,006,769 | As a general strategy, it's best to keep this data in an in-memory cache if it's static, and relatively small. Then, the 10k calls will read an in-memory cache rather than a file. Much faster.
If you are modifying the data, the alternative might be a database like SQLite, or embedded MS SQL Server (and there are others, too!).
It's not clear what kind of data this is. Is it simple config/properties data? Sometimes you can find libraries to handle the loading/manipulation/storage of this data, and it usually has it's own internal in-memory cache, all you need to do is call one or two functions.
Without more information about the files (how big are they?) and the data (how is it formatted and structured?), it's hard to say more. | 0 | 209 | false | 0 | 1 | how to speed up the code? | 3,006,810 |
4 | 5 | 0 | 2 | 1 | 1 | 0.07983 | 0 | in my program i have a method which requires about 4 files to be open each time it is called,as i require to take some data.all this data from the file i have been storing in list for manupalation.
I approximatily need to call this method about 10,000 times.which is making my program very slow?
any method for handling this files in a better ways and is storing the whole data in list time consuming what is better alternatives for list?
I can give some code,but my previous question was closed as that only confused everyone as it is a part of big program and need to be explained completely to understand,so i am not giving any code,please suggest ways thinking this as a general question...
thanks in advance | 0 | python,optimization | 2010-06-09T14:28:00.000 | 0 | 3,006,769 | Opening, closing, and reading a file 10,000 times is always going to be slow. Can you open the file once, do 10,000 operations on the list, then close the file once? | 0 | 209 | false | 0 | 1 | how to speed up the code? | 3,006,800 |
4 | 5 | 0 | 0 | 1 | 1 | 0 | 0 | in my program i have a method which requires about 4 files to be open each time it is called,as i require to take some data.all this data from the file i have been storing in list for manupalation.
I approximatily need to call this method about 10,000 times.which is making my program very slow?
any method for handling this files in a better ways and is storing the whole data in list time consuming what is better alternatives for list?
I can give some code,but my previous question was closed as that only confused everyone as it is a part of big program and need to be explained completely to understand,so i am not giving any code,please suggest ways thinking this as a general question...
thanks in advance | 0 | python,optimization | 2010-06-09T14:28:00.000 | 0 | 3,006,769 | Call the open to the file from the calling method of the one you want to run. Pass the data as parameters to the method | 0 | 209 | false | 0 | 1 | how to speed up the code? | 3,006,875 |
4 | 5 | 0 | 0 | 1 | 1 | 0 | 0 | in my program i have a method which requires about 4 files to be open each time it is called,as i require to take some data.all this data from the file i have been storing in list for manupalation.
I approximatily need to call this method about 10,000 times.which is making my program very slow?
any method for handling this files in a better ways and is storing the whole data in list time consuming what is better alternatives for list?
I can give some code,but my previous question was closed as that only confused everyone as it is a part of big program and need to be explained completely to understand,so i am not giving any code,please suggest ways thinking this as a general question...
thanks in advance | 0 | python,optimization | 2010-06-09T14:28:00.000 | 0 | 3,006,769 | If the files are structured, kinda configuration files, it might be good to use ConfigParser library, else if you have other structural format then I think it would be better to store all this data in JSON or XML and perform any necessary operations on your data | 0 | 209 | false | 0 | 1 | how to speed up the code? | 3,006,895 |
1 | 4 | 0 | 2 | 0 | 1 | 0.099668 | 0 | i want to speed my code compilation..I have searched the internet and heard that psyco is a very tool to improve the speed.i have searched but could get a site for download.
i have installed any additional libraries or modules till date in my python..
can psyco user,tell where we can download the psyco and its installation and using procedures??
i use windows vista and python 2.6 does this work on this ?? | 0 | python,optimization | 2010-06-09T16:11:00.000 | 0 | 3,007,678 | So it seems you don't want to speed up the compile but want to speed up the execution.
If that is the case, my mantra is "do less." Save off results and keep them around, don't re-read the same file(s) over and over again. Read a lot of data out of the file at once and work with it.
On files specifically, your performance will be pretty miserable if you're reading a little bit of data out of each file and switching between a number of files while doing it. Just read in each file in completion, one at a time, and then work with them. | 0 | 1,091 | false | 0 | 1 | how to speed up code? | 3,008,037 |
1 | 2 | 0 | 0 | 0 | 0 | 0 | 1 | I am looking for a way of programmatically testing a script written with the asyncore Python module. My test consists of launching the script in question -- if a TCP listen socket is opened, the test passes. Otherwise, if the script dies before getting to that point, the test fails.
The purpose of this is knowing if a nightly build works (at least up to a point) or not.
I was thinking the best way to test would be to launch the script in some kind of sandbox wrapper which waits for a socket request. I don't care about actually listening for anything on that port, just intercepting the request and using that as an indication that my test passed.
I think it would be preferable to intercept the open socket request, rather than polling at set intervals (I hate polling!). But I'm a bit out of my depths as far as how exactly to do this.
Can I do this with a shell script? Or perhaps I need to override the asyncore module at the Python level?
Thanks in advance,
- B | 0 | python,testing,sockets,wrapper | 2010-06-10T13:19:00.000 | 1 | 3,014,686 | Another option is to mock the socket module before importing the asyncore module. Of course, then you have to make sure that the mock works properly first. | 0 | 838 | false | 0 | 1 | How can I build a wrapper to wait for listening on a port? | 3,019,494 |
2 | 5 | 0 | 0 | 3 | 1 | 0 | 0 | I cannot understand it. Very simple, and obvious functionality:
You have a code in any programming language, You run it. In this code You generate variables, than You save them (the values, names, namely everything) to a file, with one command. When it's saved You may open such a file in Your code also with simple command.
It works perfect in matlab (save Workspace , load Workspace ) - in python there's some weird "pickle" protocol, which produces errors all the time, while all I want to do is save variable, and load it again in another session (?????)
f.e. You cannot save class with variables (in Matlab there's no problem)
You cannot load arrays in cPickle (but YOu can save them (?????) )
Why don't make it easier?
Is there a way to save the current variables with values, and then load them? | 0 | python,serialization | 2010-06-10T15:58:00.000 | 0 | 3,016,116 | I take issue with the statement that the saving of variables in Matlab is an environment function. the "save" statement in matlab is a function and part of the matlab language not just a command. It is a very useful function as you don't have to worry about the trivial minutia of file i/o and it handles all sorts of variables from scalar, matrix, objects, structures. | 1 | 8,265 | false | 0 | 1 | Save Workspace - save all variables to a file. Python doesn't have it) | 27,096,538 |
2 | 5 | 0 | 2 | 3 | 1 | 0.07983 | 0 | I cannot understand it. Very simple, and obvious functionality:
You have a code in any programming language, You run it. In this code You generate variables, than You save them (the values, names, namely everything) to a file, with one command. When it's saved You may open such a file in Your code also with simple command.
It works perfect in matlab (save Workspace , load Workspace ) - in python there's some weird "pickle" protocol, which produces errors all the time, while all I want to do is save variable, and load it again in another session (?????)
f.e. You cannot save class with variables (in Matlab there's no problem)
You cannot load arrays in cPickle (but YOu can save them (?????) )
Why don't make it easier?
Is there a way to save the current variables with values, and then load them? | 0 | python,serialization | 2010-06-10T15:58:00.000 | 0 | 3,016,116 | What you are describing is Matlab environment feature not a programming language.
What you need is a way to store serialized state of some object which could be easily done in almost any programming language. In python world pickle is the easiest way to achieve it and if you could provide more details about the errors it produces for you people would probably be able to give you more details on that.
In general for object oriented languages (including python) it is always a good approach to incapsulate a your state into single object that could be serialized and de-serialized and then store/load an instance of such class. Pickling and unpickling of such objects works perfectly for many developers so this must be something specific to your implementation. | 1 | 8,265 | false | 0 | 1 | Save Workspace - save all variables to a file. Python doesn't have it) | 3,016,188 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.