Q_Id int64 337 49.3M | CreationDate stringlengths 23 23 | Users Score int64 -42 1.15k | Other int64 0 1 | Python Basics and Environment int64 0 1 | System Administration and DevOps int64 0 1 | Tags stringlengths 6 105 | A_Id int64 518 72.5M | AnswerCount int64 1 64 | is_accepted bool 2
classes | Web Development int64 0 1 | GUI and Desktop Applications int64 0 1 | Answer stringlengths 6 11.6k | Available Count int64 1 31 | Q_Score int64 0 6.79k | Data Science and Machine Learning int64 0 1 | Question stringlengths 15 29k | Title stringlengths 11 150 | Score float64 -1 1.2 | Database and SQL int64 0 1 | Networking and APIs int64 0 1 | ViewCount int64 8 6.81M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2,853,113 | 2010-05-17T21:50:00.000 | 1 | 0 | 1 | 0 | python | 2,853,156 | 4 | false | 0 | 0 | Why not convert your keys to strings? Numeric keys should be pretty easy to do this with. | 3 | 0 | 0 | The python shelf module only seems to be allow string keys. Is there a way to use arbitrary typed (e.g. numeric) keys? May be an sqlite-backed dictionary?
Thanks! | Database-backed dictionary with arbitrary keys | 0.049958 | 0 | 0 | 257 |
2,853,113 | 2010-05-17T21:50:00.000 | 0 | 0 | 1 | 0 | python | 2,853,190 | 4 | false | 0 | 0 | I think you want to overload the [] operator. You can do it by defining the __getitem__ method. | 3 | 0 | 0 | The python shelf module only seems to be allow string keys. Is there a way to use arbitrary typed (e.g. numeric) keys? May be an sqlite-backed dictionary?
Thanks! | Database-backed dictionary with arbitrary keys | 0 | 0 | 0 | 257 |
2,853,113 | 2010-05-17T21:50:00.000 | 1 | 0 | 1 | 0 | python | 2,854,741 | 4 | false | 0 | 0 | You can serialize on the fly (via pickle or cPickle, like shelve.py does) every key, as well as every value. It's not really worth subclassing shelve.Shelf since you'd have to subclass almost every method -- for once, I'd instead recommend copying shelve.py into your own module and editing it to suit. That's basically like coding your new module from scratch but you get a working example to show you the structure and guidelines;-).
sqlite has no real advantage in a sufficiently general case (where the keys could be e.g. arbitrary tuples, of different arity and types for every entry) -- you're going to have to serialize the keys anyway to make them homogeneous. Still, nothing stops you from using sqlite, e.g. to keep several "generalized shelves" into a single file (different tables of the same sqlite DB) -- if you care about performance you should measure it each way, though. | 3 | 0 | 0 | The python shelf module only seems to be allow string keys. Is there a way to use arbitrary typed (e.g. numeric) keys? May be an sqlite-backed dictionary?
Thanks! | Database-backed dictionary with arbitrary keys | 0.049958 | 0 | 0 | 257 |
2,853,553 | 2010-05-17T23:09:00.000 | 0 | 0 | 1 | 0 | python | 2,983,016 | 5 | false | 0 | 0 | As far as I know, this doesn't exist. I'm hoping to start working on something similar later this year. | 2 | 3 | 0 | I'm not sure if there is even anything out there to do this. Is there any libraries out there that can reword sentences to any degree of accuracy? It doesnt have to be too intelligent. | Rewording/rephrasing english in python | 0 | 0 | 0 | 2,523 |
2,853,553 | 2010-05-17T23:09:00.000 | 0 | 0 | 1 | 0 | python | 2,855,551 | 5 | false | 0 | 0 | You can use the wordnet package to find synonyms with the same 'sense' for nouns and verbs.
But this will be a lot dumber than you want. You're looking for like, machine translation from casual english to formal english. Tough question and cool. Props to you. | 2 | 3 | 0 | I'm not sure if there is even anything out there to do this. Is there any libraries out there that can reword sentences to any degree of accuracy? It doesnt have to be too intelligent. | Rewording/rephrasing english in python | 0 | 0 | 0 | 2,523 |
2,853,708 | 2010-05-17T23:42:00.000 | 0 | 0 | 1 | 0 | python,tkinter | 2,853,858 | 1 | true | 0 | 1 | You can add buttons dynamically just fine, nothing is forcing you into the listbox. That said, I don't know why you care so much about "prettiness" since you're using Tkinter, which is very ugly by default. | 1 | 1 | 0 | I was working on a program,that I need to support new additions. Hmmm. Let me give you some background on the program.
It is an educational software program that has quizzes for the user to take, just to gain odd knowledge. Now, It currently supports 6 subjects, all organized with directores on the HDD ( i.e. the Science directory is called science. ) and the way you launch the subject to see what quizzes you have to take is by pushing a button on the home screen.
This sort of thing prevents easy subject additions. I want to be able to add a subject later on without having to recode the home screen and re organize all the buttons. I would use a Listbox and os.listdir(...), but I was kind of wanting something prettier than a Listbox. I am using Tkinter on Windows. The Python version I am using is 2.6
Is there a "fancy" listbox sort of thing that can be styled to work with the background? | Automatically support new changes with Python | 1.2 | 0 | 0 | 72 |
2,853,933 | 2010-05-18T00:40:00.000 | 0 | 0 | 0 | 0 | python,windows,random,tkinter,button | 2,864,899 | 2 | false | 0 | 1 | There are several options to choose from. For example, you could design on a grid where you have six buttons per row. Then it's just a matter of starting at row 0, incrementing the column for each button. When you get to the last column, reset the column to 0 and increment the row by one.
Another option is to use a text widget as the container, and embed your buttons in the text widget with wrapping enabled. With this trick the buttons will fill a row automatically and wrap if the user grows or shrinks the main windows. It's a tiny bit more work, but it works well if that's the behavior you want. | 1 | 0 | 0 | How do I randomly add buttons to a Tkinter GUI? I need it to be able to create a button, then put it anywhere on the window, is this possible? I am using Python 2.6 on Windows. | Randomly add buttons to Tkinter GUI? | 0 | 0 | 0 | 1,244 |
2,855,326 | 2010-05-18T07:44:00.000 | 13 | 1 | 0 | 0 | python,encryption,rsa | 2,856,628 | 1 | true | 0 | 0 | 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). | 1 | 6 | 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... | How can I create a key using RSA/ECB/PKCS1Padding in python? | 1.2 | 0 | 0 | 9,374 |
2,855,378 | 2010-05-18T07:52:00.000 | 10 | 1 | 1 | 0 | python,emacs,ide,autocomplete | 2,858,148 | 4 | false | 0 | 0 | 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. | 1 | 78 | 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) | ropemacs USAGE tutorial | 1 | 0 | 0 | 18,010 |
2,855,650 | 2010-05-18T08:34:00.000 | 1 | 1 | 0 | 0 | python,fabric | 2,857,218 | 1 | false | 1 | 0 | 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. | 1 | 0 | 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 ? | deployment public keys | 0.197375 | 0 | 0 | 212 |
2,856,356 | 2010-05-18T10:30:00.000 | 1 | 0 | 0 | 0 | python,django,telnet,telnetlib | 2,856,596 | 1 | true | 0 | 0 | The usual way would be to have a process running in the background that keeps hold of the persistent telnet connections and commands queued to go down them.
Then have the front-end scripts connect to it (eg. via a unix socket) to queue commands and get the results asynchronously.
But this might be overkill. How many people are you expecting to be using a switch interface concurrently? A lightweight alternative for just the web part of it would be to keep the telnet connection object in the web scripts, and configure the web server/gateway to only launch one instance of your webapp at once. | 1 | 0 | 0 | I am programming web interface which communicates with cisco switches via telnet. I want to make such system which will be storing one telnet connection per switch and every script (web interface, cron jobs, etc.) will have access to it. This is needed to make a single query queue for each device and prevent huge cisco processor load caused by several concurent telnet connections.
How do I can do this?
updated
Option with connection handling daemon is good and will work in the best way. Sharing telnet connection object between scripts may be difficult to implement and debug. But this option is interesting because interface is using only by couple of operators and cron jobs. | Python (Django). Store telnet connection | 1.2 | 0 | 1 | 1,334 |
2,856,403 | 2010-05-18T10:40:00.000 | 1 | 0 | 0 | 0 | python,django,mod-wsgi | 2,856,435 | 1 | true | 1 | 0 | In embedded mode, the Django app is part of the httpd worker. In daemon mode, the Django app is a separate process and the httpd worker communicates with it over a socket. In either case, the WSGI interface is the same. | 1 | 1 | 0 | When you use Django with mod_wsgi, what exactly happens when a user makes a request to the server from a browser? Does apache load up your Django app when it starts and have it running in a separate process? Does it create a new Python process for every HTTP request? | Using Django with mod_wsgi | 1.2 | 0 | 0 | 189 |
2,857,273 | 2010-05-18T12:40:00.000 | 2 | 1 | 0 | 0 | python,ssl,wsgi,gevent | 2,857,301 | 3 | false | 1 | 0 | I would let the http server deal with the ssl transport. | 1 | 5 | 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? | SSL and WSGI apps - Python | 0.132549 | 0 | 0 | 7,474 |
2,857,634 | 2010-05-18T13:24:00.000 | 0 | 0 | 0 | 0 | python,xml,user-interface,gtk,glade | 2,857,711 | 4 | false | 0 | 1 | I don't recommend doing a GUI in XML. All the XML does is give you a mini language for describing a layout. Why use a mini language when you can have the full power of python?
As for detecting GTK, I wouldn't suggest that. Instead, add a command line argument to determine whether to create a GUI or not (eg: myprogram -g). It then becomes easy to create a desktop shortcut or command line alias to start in GUI mode, while still being able to use the command line tool from any terminal.
You do, however, want to keep the GUI code separate from the bits that do the real work. Give youself a class that contains all the business logic, then have the GUI and CLI both access this object to do work. | 1 | 2 | 0 | I am trying to write an app in python to control a motor using serial. This all works in a CLI situation fine and is generally stable. but I was wondering how simple it was to add a GUI on top of this code base?
I assume there will be more code, but is there a simple way of detecting something like GTK, so it only applied the code when GTK was present?
Also, GUI creation in Python in general: is it best to keep as little GUI specifics out of the code and use something like GTK's XML based approach (using gtk.glade.XML() function)? Are there other GUI toolkits that have a similar approach to the Glade / XML / "Explode in Code" approach?
Thanks for any advice.
Andy | How can I create a GUI on top of a Python APP so it can do either GUI or CLI? | 0 | 0 | 0 | 1,570 |
2,858,040 | 2010-05-18T14:14:00.000 | 2 | 0 | 0 | 0 | python,django,permissions,inlines | 3,090,090 | 1 | true | 1 | 0 | If I want a read-only version of what's in the admin, I just write some normal Django views and keep them out of the admin.
I don't think the kind of thing you're talking about (allowing changes to an object but not its inlines) is really supported by the admin. Don't get me wrong: the admin is very flexible and useful, but it's not intended to do everything for you.
The only way I see you being able to have this much control in the admin is to not inline A.
"If you don't trust U, just deny him access to the admin area all together". Kind of a stupid doctrine.
Not really, when you consider that the admin isn't intended to have the required level of security hardening to guarantee that fine-grain level of access control. There are many, many places in the admin, due to its open and extensible nature, where bugs can lurk (usually in user-written code) that can be exploited by bad actors. This is why untrusted users should always see all admin URLs return 404.
Anyway, when access control requirements are that fine-grained, it becomes unlikely that a general (i.e. django.contrib) solution will fit. | 1 | 9 | 0 | I'm not sure if this is a bug or I'm just missing something (although I have already parsed the documentation about inlines), but:
Let's say I have a model A. Model A is an inline of model B. User U has full access to model B, but only change permissions to model A (so, no add, nor delete).
However, when editing model B, user U can still see the "Add another A" link at the bottom, although U hasn't add permissions for that respective model.
What's wrong? Why does that link keep on showing? My logic says that if U does not have permissions to add A, the link shouldn't appear anymore.
Also, ideally, I would like to give U only view rights to model A (so no add, delete or change - only view), but I've read about that (strange, if you ask me) philosophy according to which "If you don't trust U, just deny him access to the admin area all together". Kind of a stupid doctrine.
Right now, I'm trying to simulate this 'view only permissions' by leaving U with just change rights and set all fields as read only. But I think this is kind of a stupid approach and may also cause problems like the permissions thing above...
How does an average Django programmer like me achieve view-only permissions, and most of all how should I get rid of the "Add another A" link at the bottom of the admin edit form?
Thanks in advance! | Django Inlines user permissions + view only - permissions issues | 1.2 | 0 | 0 | 1,938 |
2,859,413 | 2010-05-18T17:06:00.000 | 8 | 0 | 0 | 0 | python,packaging,zipapp | 2,861,524 | 1 | true | 0 | 1 | I figured out by myself, It's sufficient to use pkgutil.get_data to access the data inside a package. | 1 | 4 | 0 | I'm doing a little program and I want to distribute it using this recipe:
single directory with __main__.py in it
zip this directory and adding a shebang on it #!/usr/bin/env python
making it executable
The problem is that in this package I have also extra files (I'm using pygtk toolkit and I need images and ui xml files). When I try to access these files I have the error that the resource is unavailable (the path that I'm trying to open is something like file.zip/gui/gui.ui ).
How can I handle this situation? | Distributing an executable zip file with __main__.py, how to access extra data? | 1.2 | 0 | 0 | 2,816 |
2,860,106 | 2010-05-18T18:50:00.000 | 2 | 0 | 1 | 0 | python,oop | 2,860,167 | 4 | false | 0 | 0 | Of course. There is no need to create a base class or an interface in this case either, as everything is dynamic. | 2 | 6 | 0 | Would it be possible to create a class interface in python and various implementations of the interface.
Example: I want to create a class for pop3 access (and all methods etc.). If I go with a commercial component, I want to wrap it to adhere to a contract.
In the future, if I want to use another component or code my own, I want to be able to swap things out and not have things very tightly coupled.
Possible? I'm new to python. | Creating an interface and swappable implementations in python | 0.099668 | 0 | 0 | 985 |
2,860,106 | 2010-05-18T18:50:00.000 | 0 | 0 | 1 | 0 | python,oop | 2,860,130 | 4 | false | 0 | 0 | Yes, this is possible. There are typically no impediments to doing so: just keep a stable API and change how you implement it. | 2 | 6 | 0 | Would it be possible to create a class interface in python and various implementations of the interface.
Example: I want to create a class for pop3 access (and all methods etc.). If I go with a commercial component, I want to wrap it to adhere to a contract.
In the future, if I want to use another component or code my own, I want to be able to swap things out and not have things very tightly coupled.
Possible? I'm new to python. | Creating an interface and swappable implementations in python | 0 | 0 | 0 | 985 |
2,860,339 | 2010-05-18T19:17:00.000 | 4 | 0 | 1 | 0 | python,random,set,shuffle | 2,860,358 | 5 | false | 0 | 0 | No, you can not rely on it for any real statistical purpose. The implementation of sets in Python is in terms of a hash table, and can cause the element distribution to display some very non-random properties. There's a large gap between "not having a guaranteed order" and "guaranteed to be unordered in a uniform-random manner".
Use random.shuffle to really shuffle elements of a sequence. | 3 | 18 | 0 | I'd like to know if the absence of element ordering of the Python's built-in set structure is "random enough". For instance, taking the iterator of a set, can it be considered a shuffled view of its elements?
(If it matters, I'm running Python 2.6.5 on a Windows host.) | Can Python's set absence of ordering be considered random order? | 0.158649 | 0 | 0 | 4,167 |
2,860,339 | 2010-05-18T19:17:00.000 | 4 | 0 | 1 | 0 | python,random,set,shuffle | 2,860,554 | 5 | false | 0 | 0 | Arbitrariness is central when designing programs, each of these freedoms that you reserve is like a joker card that you can use when you implement, develop, or rewrite your program. The more of these free-cards you collect, the more efficiency can you deliver from your code (probably), since you have more freedom to change it.
It is not random, it's only freedom. If it's a better set that way, the order can be forwards on Wednesdays and "backwards" on Fridays. | 3 | 18 | 0 | I'd like to know if the absence of element ordering of the Python's built-in set structure is "random enough". For instance, taking the iterator of a set, can it be considered a shuffled view of its elements?
(If it matters, I'm running Python 2.6.5 on a Windows host.) | Can Python's set absence of ordering be considered random order? | 0.158649 | 0 | 0 | 4,167 |
2,860,339 | 2010-05-18T19:17:00.000 | 34 | 0 | 1 | 0 | python,random,set,shuffle | 2,860,350 | 5 | true | 0 | 0 | No, it is not random. It is "arbitrarily ordered", which means that you cannot depend on it being either ordered or random. | 3 | 18 | 0 | I'd like to know if the absence of element ordering of the Python's built-in set structure is "random enough". For instance, taking the iterator of a set, can it be considered a shuffled view of its elements?
(If it matters, I'm running Python 2.6.5 on a Windows host.) | Can Python's set absence of ordering be considered random order? | 1.2 | 0 | 0 | 4,167 |
2,860,386 | 2010-05-18T19:25:00.000 | 2 | 0 | 0 | 1 | python,emacs | 2,884,416 | 3 | false | 0 | 0 | You should look into the other shell modes. TERM-MODE and ANSI-MODE. I believe they can support interactive command line programs. | 2 | 5 | 0 | If I use M-x shell and run the interactive Python interpreter, Emacs on Windows does not return any IO.
When I discovered M-x python-shell, I regained hope. However, instead of running the interactive Python shell, I want to run a specific Python script that features an interactive CLI. (See Python's cmd module for details).
Is there a way of launching a Python script in Emacs that is interactive? (stdout, stdin, stderr) | How do I run an interactive command line Python app inside of Emacs on Win32? | 0.132549 | 0 | 0 | 820 |
2,860,386 | 2010-05-18T19:25:00.000 | -1 | 0 | 0 | 1 | python,emacs | 21,938,935 | 3 | false | 0 | 0 | You can run python in interactive mode by typing python.exe -i
Alternatively, you can download ipython and just run ipython.exe | 2 | 5 | 0 | If I use M-x shell and run the interactive Python interpreter, Emacs on Windows does not return any IO.
When I discovered M-x python-shell, I regained hope. However, instead of running the interactive Python shell, I want to run a specific Python script that features an interactive CLI. (See Python's cmd module for details).
Is there a way of launching a Python script in Emacs that is interactive? (stdout, stdin, stderr) | How do I run an interactive command line Python app inside of Emacs on Win32? | -0.066568 | 0 | 0 | 820 |
2,860,650 | 2010-05-18T19:58:00.000 | 0 | 0 | 0 | 0 | python,qt,pyqt,process,jython | 2,861,467 | 2 | false | 1 | 1 | If the criteria is not reinventing the wheel, there is the SimpleXMLRPCServer and xmlrpclib modules available in the standard library. They should work in Jython too. | 1 | 3 | 0 | I am about to begin a project where I will likely use PyQt or Pyside.
I will need to interface with a buggy 3rd party piece of server software that provides C++ and Java APIs. The Java APIs are a lot easier to use because you get Exceptions where with the C++ libraries you get segfaults. Also, the Python bindings to the Java APIs are automatic with Jython whereas the Python bindings for the C++ APIs don't exist.
So, how would a CPython PyQt client application be able to communicate with these Java APIs? How would you go about it?
Would you have another separate Java process on the client that serializes / pickles objects and communicates with the PyQt process over a socket?
I don't want to re-invent the wheel... is there some sort of standard interface for these types of things? Some technology I should look into? RPC, Corba, etc?
Thanks,
~Eric | Integrating Jython Cpython | 0 | 0 | 0 | 1,047 |
2,861,183 | 2010-05-18T21:10:00.000 | 59 | 0 | 1 | 0 | python,virtualenv,pip | 2,880,884 | 3 | false | 0 | 0 | I just tried on my virtualenv project and pip install -U --no-deps mypackage seems to work just fine. It just download mypackage and nothing else. What's your set up like? | 1 | 64 | 0 | I'm using pip and virtualenv for my python application. I would like to upgrade to a new version of the application without touching the dependencies. When I use pip install -U, it tries to upgrade all the packages, and even uninstalls and re-installs the same version of a dependency package when there isn't a new version available.
I also tried pip install -U --no-deps but that seems equivalent to a regular install instead of an upgrade. Is there a combination of flags that will do what I want? | Upgrade package without upgrading dependencies using pip? | 1 | 0 | 0 | 42,784 |
2,861,575 | 2010-05-18T22:24:00.000 | 0 | 0 | 1 | 0 | python | 2,861,718 | 5 | false | 0 | 0 | It might be useful to get some information on Object Oriented programming (just what is the whole class thing about, and how do you tell if your classes are good/poor/indifferent). Mark Lutz' book Learning Python has an entire Part (several chapters) on OO. If this stuff is new to you, it might be helpful to take a look. Two other books I have found quite useful: The Python Cookbook (Alex Martelli, a prolific contributor here), and the Python Essential Reference (David Beazley). | 1 | 3 | 0 | I've started to learn Python and programming from scratch. I have not programmed before so it's a new experience. I do seem to grasp most of the concepts, from variables to definitions and modules. I still need to learn a lot more about what the different libraries and modules do and also I lack knowledge on OOP and classes in Python.
I see people who just program in Python like that's all they have ever done and I am still just coming to grips with it.
Is there a way, some tools, a logical methodology that would give me an overview or a good hold of how to handle programming problems ?
For instance, I'm trying to create a parser which we need at the office . I also need to create a spider that would collect links from various websites.
Is there a formidable way of studying the various modules to see what is needed ? Or is it just nose to the grind stone and understand what the documentation says ?
Sorry for the lengthy question.. | How do I get an overview and a methodology for programming in Python | 0 | 0 | 0 | 178 |
2,861,583 | 2010-05-18T22:26:00.000 | 3 | 0 | 1 | 0 | python,datetime,unicode | 2,861,641 | 3 | false | 0 | 0 | Converting with unicode() or string.decode() like in your example should work. The only problem should be that in your example you use the default locale's encoding even though you set the locale to something different before. If you use locale.getlocale()[1] instead of locale.getdefaultlocale()[1] you should get the correct results. | 1 | 2 | 0 | I would like to convert datetime.ctime() values to Unicode.
Using Python 2.6.4 running under Windows I can set my locale to Spanish like below:
>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'esp' )
Then I can pass %a, %A, %b, and %B to ctime() to get day and month names and abbreviations.
>>> import datetime
>>> dateValue = datetime.date( 2010, 5, 15 )
>>> dayName = dateValue.strftime( '%A' )
>>> dayName
's\xe1bado'
How do I convert the 's\xe1bado' value to Unicode? Specifically what encoding do I use?
I'm thinking I might do something like the following, but I'm not sure this is the right approach.
>>> codePage = locale.getdefaultlocale()[ 1 ]
>>> dayNameUnicode = unicode( dayName, codePage )
>>> dayNameUnicode
u's\xe1bado'
Malcolm | Converting datetime.ctime() values to Unicode | 0.197375 | 0 | 0 | 2,315 |
2,861,858 | 2010-05-18T23:22:00.000 | -2 | 0 | 0 | 1 | python,asynchronous,twisted | 2,899,163 | 2 | false | 0 | 0 | You might also like the txRDQ (Resizable Dispatch Queue) I wrote. Google it, it's in the tx collection on LaunchPad. Sorry I don't have more time to reply - about to go onstage.
Terry | 1 | 11 | 0 | The strength of Twisted (for python) is its asynchronous framework (I think). I've written an image processing server that takes requests via Perspective Broker. It works great as long as I feed it less than a couple hundred images at a time. However, sometimes it gets spiked with hundreds of images at virtually the same time. Because it tries to process them all concurrently the server crashes.
As a solution I'd like to queue up the remote_calls on the server so that it only processes ~100 images at a time. It seems like this might be something that Twisted already does, but I can't seem to find it. Any ideas on how to start implementing this? A point in the right direction? Thanks! | Queue remote calls to a Python Twisted perspective broker? | -0.197375 | 0 | 0 | 6,156 |
2,862,659 | 2010-05-19T03:30:00.000 | 0 | 0 | 0 | 0 | python,image-manipulation,python-imaging-library | 2,862,756 | 3 | false | 0 | 0 | One obvious way is to use Image.getpixel and Image.putpixel, for RGB, each should be a tuple of three integers. You can get (255-r, 255-g, 255-b), then put it back.
Or use pix = Image.load(), which seems faster.
Or if you look into ImageOps.py, it's using a lookup table (lut list) to map an image to an inverted one.
Or if it's not against the rules of your assignment, you may use Numpy. Then you can use the faster matrix operation. | 1 | 1 | 0 | I'm interested in learning how to invert (make a negative of) an image using the python image libary module.
I cannot however, use the ImageOps function 'invert.' I need another solution, using the RGB values. I've searched and tried to no avail. | Inverting image using the Python Image Library module | 0 | 0 | 0 | 3,836 |
2,863,618 | 2010-05-19T07:36:00.000 | 1 | 1 | 0 | 0 | apache,mod-python,mod-php | 2,863,923 | 2 | false | 0 | 0 | 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. | 2 | 3 | 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. | Web programming: Apache modules: mod_python vs mod_php | 0.099668 | 0 | 0 | 1,262 |
2,863,618 | 2010-05-19T07:36:00.000 | 2 | 1 | 0 | 0 | apache,mod-python,mod-php | 2,869,850 | 2 | true | 0 | 0 | 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. | 2 | 3 | 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. | Web programming: Apache modules: mod_python vs mod_php | 1.2 | 0 | 0 | 1,262 |
2,863,748 | 2010-05-19T07:59:00.000 | 1 | 0 | 0 | 0 | python,sqlalchemy | 2,863,830 | 1 | false | 1 | 0 | Sorting is done by the database. If you database doesn't support natural sorting your are out of luck and have to sort your rows manually after retrieving them via sqlalchemy. | 1 | 1 | 0 | Currently, i am querying with this code: meta.Session.query(Label).order_by(Label.name).all()
and it returns me objects sorted by Label.name in this manner ['1','7','1a','5c']. Is there a way i can have the objects returned in the order with their Label.name sorted like this ['1','1a','5c','7']
Thanks! | sqlalchemy natural sorting | 0.197375 | 1 | 0 | 1,746 |
2,864,277 | 2010-05-19T09:32:00.000 | 3 | 0 | 1 | 1 | python,linux,unix | 2,864,298 | 1 | false | 0 | 0 | Use Popen from subprocess like this
process = Popen("cmd", shell=True, bufsize=bufsize, stdout=PIPE)
Then use process.stdout to read from program's stdout (like reading from any other file like object). | 1 | 0 | 0 | i'm looking for a way in python to run an external binary and watch it's output for: "up to date" If "up to date" isn't returned i want to run the original command again, once "up to date" is displayed i would like to be able to run another script. So far I've figured out how to run the binary with options using subprocess but thats as far as I've gotten. Thanks! | call external program in python, watch output for specific text then take action | 0.53705 | 0 | 0 | 720 |
2,864,366 | 2010-05-19T09:47:00.000 | 7 | 0 | 1 | 0 | python,class,naming-conventions | 2,864,397 | 2 | false | 0 | 0 | No, you can define multiple classes (and functions, etc.) in a single file. A file is also called a module.
To use the classes/functions defined in the module/file, you will need to import the module/file. | 1 | 54 | 0 | Much like Java (or php), I'm use to seperating the classes to files.
Is it the same deal in Python? plus, how should I name the file?
Lowercase like classname.py or the same like ClassName.py?
Do I need to do something special if I want to create an object from this class or does the fact that it's in the same "project" (netbeans) makes it ok to create an object from it? | Are classes in Python in different files? | 1 | 0 | 0 | 91,527 |
2,864,663 | 2010-05-19T10:33:00.000 | 1 | 1 | 0 | 1 | python,twisted,telnet | 2,864,683 | 2 | false | 0 | 0 | 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. | 1 | 4 | 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. | Twisted Matrix and telnet server implementation | 0.099668 | 0 | 0 | 2,482 |
2,865,003 | 2010-05-19T11:25:00.000 | 0 | 0 | 0 | 0 | python,pygame | 2,897,004 | 7 | false | 0 | 1 | No one has mentioned this yet as a source of games written in pygame, but check out www.pyweek.org - it's a week-long programming competition featuring games built in python. In many cases they use pygame, though there are other libs such as pyglet and opengl that are used. | 1 | 13 | 0 | Just curious if anyone knows of good sites for learning and understanding PyGame.
I've programmed a bunch in Python, so I'm well-equipped with that. Just curious if anyone knows a good site or more for learning PyGame.
Thanks for any help! | Best resources for learning PyGame? | 0 | 0 | 0 | 7,938 |
2,865,679 | 2010-05-19T13:01:00.000 | 5 | 0 | 1 | 0 | python,c | 2,865,722 | 2 | true | 0 | 0 | You can't make a statically linked extension module because Python needs to load it dynamically at runtime and because (as you reasoned) the module needs to dynamically link against libpython.
You could compile your own custom version of Python with your extension statically linked into the interpreter. That's usually more trouble than it's worth.
Why do you want to make a statically linked extension? If we have more information about your goals, we might be able to help you achieve them in a different way.
Welcome to StackOverflow. :-) | 1 | 6 | 0 | I'm an extension noob. What I want to do is create an extension that doesn't require other libraries to be installed. Is this impossible because the extension has to link against a specific version of libpython at runtime? | Why are python extensions shared libraries? Is it possible to make a static-linked library? | 1.2 | 0 | 0 | 2,127 |
2,870,092 | 2010-05-19T23:17:00.000 | 0 | 0 | 1 | 0 | python,matplotlib,macports,enthought | 14,721,335 | 2 | false | 0 | 0 | I've used EPD on Windows 7. It works great. Only stalled on me a couple of times with rather large data set.
I also use OSX, and was about to install EPD but hesitating a bit.
I think python 2.7.3 that comes with EPD (early 2013) will become the default python. Normally, upgrading to 2.7 from 2.6 should not be much of problem based on my personal experience. But I am a bit concerned to have 2 versions of 2.7 and what kind of impact it will have on using GAE SDK on my OSX. (Upgrading created a bit of hassle with GAE SKD.)
Here is what EPD readme says:
A full installation will install the following:
* Python framework -- installed into:
/Library/Frameworks/Python.framework/Versions/7.3
Python applications -- installed into
/Applications/Enthought
System fixes -- makes the EPD Python your default one by adding lines to
your .bash_profile to your path.
I think I will sleep on this. | 2 | 2 | 0 | I've been using MacPorts Python 2.6 on OS X 10.6.
I am considering also installing the Enthought Python Distribution (EPD) on the same machine because it comes preconfigured with matplotlib and other nice data analysis and visualization packages.
Can the two Python distributions co-exist peacefully on the same machine?
What potential problems will I have to look out for (e.g., environment variables)?
I know that building matplotlib through MacPorts is an option, but the process is lengthy (on the order of a full day) and there are open questions about compiling some dependencies on 64bit Intel.
I would like to know about the tradeoffs before committing to one of the two approaches. | Can EPD Python and MacPorts Python coexist on OS X (matplotlib)? | 0 | 0 | 0 | 763 |
2,870,092 | 2010-05-19T23:17:00.000 | 3 | 0 | 1 | 0 | python,matplotlib,macports,enthought | 2,874,199 | 2 | true | 0 | 0 | I'm not an OSX user, so I can't say for certain, but you should be fine.
EPD bundles its own python interpreter and all required libraries. The installer basically just extracts a tarball into a stand-alone folder.
The linux installer doesn't modify any environment variables (not even $PATH), so I assume the mac installer is similar.
(Because of this, you'll probably want to manually set up aliases to the EPD python/ipython/etc binaries so you can more easily call them without changing your $PATH.)
EPD really should be completely stand-alone, as far as I know. It should be safe to install along-side anything else. | 2 | 2 | 0 | I've been using MacPorts Python 2.6 on OS X 10.6.
I am considering also installing the Enthought Python Distribution (EPD) on the same machine because it comes preconfigured with matplotlib and other nice data analysis and visualization packages.
Can the two Python distributions co-exist peacefully on the same machine?
What potential problems will I have to look out for (e.g., environment variables)?
I know that building matplotlib through MacPorts is an option, but the process is lengthy (on the order of a full day) and there are open questions about compiling some dependencies on 64bit Intel.
I would like to know about the tradeoffs before committing to one of the two approaches. | Can EPD Python and MacPorts Python coexist on OS X (matplotlib)? | 1.2 | 0 | 0 | 763 |
2,870,292 | 2010-05-20T00:13:00.000 | 0 | 0 | 1 | 0 | java,python,conventions,readability | 2,870,528 | 6 | false | 0 | 0 | "Everything is a class" is a Java idiom that's specifically not a Python idiom. (Almost) everything can be a class in Python, and if that's more comfortable for you then go for it, but Python doesn't require such a thing. Python is not a purely object-oriented language, and in my (limited) experience it's good to take that to heart. | 1 | 9 | 0 | I'm a java programmer, but now entering the "realm of python" for some stuff for which Python works better. I'm quite sure a good portion of my code would look weird for a Python programmer (e.g. using parenthesis on every if).
I know each language has its own conventions and set of "habits". So, from a readability standpoint what are conventions and practices which is "the way to go" in Java, but are not really the "pythonic way" to do stuff? | Python readability hints for a Java programmer | 0 | 0 | 0 | 899 |
2,870,379 | 2010-05-20T00:47:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine,sqlite | 2,873,946 | 4 | false | 1 | 0 | I have not had any trouble importing pysqlite2, reading data, then transforming it and writing it to AppEngine using the remote_api.
What error are you seeing? | 1 | 5 | 0 | I have a relatively extensive sqlite database that I'd like to import into my Google App Engine python app.
I've created my models using the appengine API which are close, but not quite identical to the existing schema. I've written an import script to load the data from sqlite and create/save new appengine objects, but the appengine environment blocks me from accessing the sqlite library. This script is only to be run on my local app engine instance, and from there I hope to push the data to google.
Am I approaching this problem the wrong way, or is there a way to import the sqlite library while running in the local instance's environment? | Importing Sqlite data into Google App Engine | 0 | 1 | 0 | 2,231 |
2,870,815 | 2010-05-20T03:24:00.000 | 2 | 0 | 0 | 0 | python,sql,database | 2,870,821 | 3 | false | 0 | 0 | No, I think you just stick to dictionaries or tuples if you only have rows around 100 | 3 | 1 | 0 | I am working on a personal project where I need to manipulate values in a database-like format.
Up until now I have been using dictionaries, tuples, and lists to store and consult those values.
I am thinking about starting to use SQL to manipulate those values, but I don't know if it's worth the effort, because I don't know anything about SQL, and I don't want to use something that won't bring me any benefits (if I can do it in a simpler way, I don't want to complicate things)
If I am only storing and consulting values, what would be the benefit of using SQL?
PS: the numbers of rows goes between 3 and 100 and the number of columns is around 10 (some may have 5 some may have 10 etc.) | Python and database | 0.132549 | 1 | 0 | 291 |
2,870,815 | 2010-05-20T03:24:00.000 | 7 | 0 | 0 | 0 | python,sql,database | 2,870,832 | 3 | true | 0 | 0 | SQL is nice and practical for many kinds of problems, is not that hard to learn at a simple "surface" level, and can be very handy to use in Python with its embedded sqlite. But if you don't know SQL, have no intrinsic motivation to learn it right now, and are already doing all you need to do to/with your data without problems, then the immediate return on the investment of learning SQL (relatively small as that investment may be) seem like it would be pretty meager indeed for you. | 3 | 1 | 0 | I am working on a personal project where I need to manipulate values in a database-like format.
Up until now I have been using dictionaries, tuples, and lists to store and consult those values.
I am thinking about starting to use SQL to manipulate those values, but I don't know if it's worth the effort, because I don't know anything about SQL, and I don't want to use something that won't bring me any benefits (if I can do it in a simpler way, I don't want to complicate things)
If I am only storing and consulting values, what would be the benefit of using SQL?
PS: the numbers of rows goes between 3 and 100 and the number of columns is around 10 (some may have 5 some may have 10 etc.) | Python and database | 1.2 | 1 | 0 | 291 |
2,870,815 | 2010-05-20T03:24:00.000 | 2 | 0 | 0 | 0 | python,sql,database | 2,871,090 | 3 | false | 0 | 0 | SQL is useful in many applications. But it is an overkill in this case. You can easily store your data in CSV, pickle or JSON format. Get this job done in 5 minutes and then learn SQL when you have time. | 3 | 1 | 0 | I am working on a personal project where I need to manipulate values in a database-like format.
Up until now I have been using dictionaries, tuples, and lists to store and consult those values.
I am thinking about starting to use SQL to manipulate those values, but I don't know if it's worth the effort, because I don't know anything about SQL, and I don't want to use something that won't bring me any benefits (if I can do it in a simpler way, I don't want to complicate things)
If I am only storing and consulting values, what would be the benefit of using SQL?
PS: the numbers of rows goes between 3 and 100 and the number of columns is around 10 (some may have 5 some may have 10 etc.) | Python and database | 0.132549 | 1 | 0 | 291 |
2,872,041 | 2010-05-20T08:20:00.000 | 1 | 1 | 0 | 1 | python,perl,bash,scripting,comparison | 3,203,607 | 18 | false | 0 | 0 | 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. | 10 | 76 | 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? | Is there any use for Bash scripting anymore? | 0.011111 | 0 | 0 | 50,948 |
2,872,041 | 2010-05-20T08:20:00.000 | 1 | 1 | 0 | 1 | python,perl,bash,scripting,comparison | 3,147,413 | 18 | false | 0 | 0 | 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. | 10 | 76 | 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? | Is there any use for Bash scripting anymore? | 0.011111 | 0 | 0 | 50,948 |
2,872,041 | 2010-05-20T08:20:00.000 | 2 | 1 | 0 | 1 | python,perl,bash,scripting,comparison | 2,877,257 | 18 | false | 0 | 0 | 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). | 10 | 76 | 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? | Is there any use for Bash scripting anymore? | 0.022219 | 0 | 0 | 50,948 |
2,872,041 | 2010-05-20T08:20:00.000 | 1 | 1 | 0 | 1 | python,perl,bash,scripting,comparison | 2,875,733 | 18 | false | 0 | 0 | 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. | 10 | 76 | 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? | Is there any use for Bash scripting anymore? | 0.011111 | 0 | 0 | 50,948 |
2,872,041 | 2010-05-20T08:20:00.000 | 2 | 1 | 0 | 1 | python,perl,bash,scripting,comparison | 2,872,083 | 18 | false | 0 | 0 | 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. | 10 | 76 | 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? | Is there any use for Bash scripting anymore? | 0.022219 | 0 | 0 | 50,948 |
2,872,041 | 2010-05-20T08:20:00.000 | 8 | 1 | 0 | 1 | python,perl,bash,scripting,comparison | 2,872,064 | 18 | false | 0 | 0 | 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. | 10 | 76 | 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? | Is there any use for Bash scripting anymore? | 1 | 0 | 0 | 50,948 |
2,872,041 | 2010-05-20T08:20:00.000 | 2 | 1 | 0 | 1 | python,perl,bash,scripting,comparison | 2,874,267 | 18 | false | 0 | 0 | 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. | 10 | 76 | 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? | Is there any use for Bash scripting anymore? | 0.022219 | 0 | 0 | 50,948 |
2,872,041 | 2010-05-20T08:20:00.000 | 4 | 1 | 0 | 1 | python,perl,bash,scripting,comparison | 2,875,677 | 18 | false | 0 | 0 | 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. | 10 | 76 | 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? | Is there any use for Bash scripting anymore? | 0.044415 | 0 | 0 | 50,948 |
2,872,041 | 2010-05-20T08:20:00.000 | 2 | 1 | 0 | 1 | python,perl,bash,scripting,comparison | 2,872,085 | 18 | false | 0 | 0 | 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. | 10 | 76 | 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? | Is there any use for Bash scripting anymore? | 0.022219 | 0 | 0 | 50,948 |
2,872,041 | 2010-05-20T08:20:00.000 | 26 | 1 | 0 | 1 | python,perl,bash,scripting,comparison | 2,872,171 | 18 | false | 0 | 0 | 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. | 10 | 76 | 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? | Is there any use for Bash scripting anymore? | 1 | 0 | 0 | 50,948 |
2,874,431 | 2010-05-20T14:02:00.000 | 5 | 1 | 1 | 0 | python,configuration,import,config | 2,874,547 | 3 | true | 0 | 0 | Use the __import__ builtin function. But like nosklo, I prefer to store it in simpler data format like JSON of INI config file. | 2 | 1 | 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? | What's the best way to use python-syntax config files (in python of course)? | 1.2 | 0 | 0 | 564 |
2,874,431 | 2010-05-20T14:02:00.000 | 1 | 1 | 1 | 0 | python,configuration,import,config | 2,877,557 | 3 | false | 0 | 0 | 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. | 2 | 1 | 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? | What's the best way to use python-syntax config files (in python of course)? | 0.066568 | 0 | 0 | 564 |
2,875,530 | 2010-05-20T15:55:00.000 | 6 | 0 | 1 | 0 | python,cx-freeze | 2,875,948 | 1 | true | 0 | 1 | Disclaimer: I haven't used cx_Freeze in awhile......
.PYD files are DLL machine-code files that contain specific python-required functions.
.PYC files are .py files that have been compiled into bytecode.
so PYDs are machine code and PYCs are bytecode
Now as for why the PYDs aren't in the .zip....I'd imagine it's because those .PYDs are needed by the python interpreter to run the program. What cx_Freeze does is basically this:
compile all .py files and throw the .pyc files in a zip
put all needed .pyd files in the zip
create a stub .py file and put it in the output directory
copy the python.exe and rename to myprogram.exe
copy all .pyd files needed to open the .zip and run the contents
So you're not actually compiling your python file, you're instead renaming the interpeter and freezing all the source files.
I hope this helps. | 1 | 3 | 0 | I'm using cx_Freeze to freeze my python program. On running cx_Freeze, a bunch of PYD files are created, a whole bunch of PYC files are put into a archive named library.zip and a few DLL files are there too.
Could someone tell me the difference between the PYC and the PYD files?
What's the reason for the PYD files not in the library.zip?
Is it possible to put the PYD files into the archive as well?
Thanks. | cx_Freeze and PYC/PYD files | 1.2 | 0 | 0 | 3,772 |
2,876,181 | 2010-05-20T17:17:00.000 | 0 | 0 | 0 | 1 | python,asynchronous,file-upload | 19,850,039 | 2 | false | 0 | 0 | See if you can push the files straight from the user's browser to a static file store, like Amazon S3 or rackspace's cloudfiles service.
Then you can handle a ton of parallel users. | 1 | 3 | 0 | We have a web application that takes file uploads for some parts. The file uploads aren't terribly big (mostly word documents and such), but they're much larger than your typical web request and they tend to tie up our threaded servers (zope 2 servers running behind an Apache proxy).
I'm mostly in the brainstorming phase right now and trying to figure out a general technique to use. Some ideas I have are:
Using a python asynchronous server like tornado or diesel or gunicorn.
Writing something in twisted to handle it.
Just using nginx to handle the actual file uploads.
It's surprisingly difficult to find information on which approach I should be taking. I'm sure there are plenty of details that would be needed to make an actual decision, but I'm more worried about figuring out how to make this decision than anything else. Can anyone give me some advice about how to proceed with this? | What's the most scalable way to handle somewhat large file uploads in a Python webapp? | 0 | 0 | 0 | 672 |
2,876,337 | 2010-05-20T17:36:00.000 | 1 | 0 | 1 | 0 | python,django | 2,888,075 | 10 | false | 1 | 0 | If it is your basics in OOPS that you wish to strengthen, Java is a good option(provided you know c++ or any other non-web-based language which supports OOPS). However, if you are looking towards web-development, Python should be your best option.
Yes, Python is a good option
Yes, Django is a very good web application framework(and they have awesome documentation and tutorials put up at their site)
To learn Python I definitely recommend reading "The Python Cookbook" cover-to-cover. Its fun, and covers some very important concepts. However, there really is no substitute for the standard python documentation. Its well written, but it might take a while through a major portion of it. Using it as just reference material is also a fine idea.
Well I have seen domains which allow Django to be hosted; also you should try out the GAE(google app engine) once you are comfortable with django. Its a great place to host your apps. | 1 | 11 | 0 | I am currently learning PHP and want to learn about OOP.
I know Python is a well-organized and is all OOP, so would learning Python be a wise choose to learn OOP?
The thing is I am more towards web development then just general programming, and I know Python is just a general purpose language, but there is Django.
So how should I go about learning Python if I am lending towards web development?
Is there any good books/websites that help me learn Python for web development?
Is there any free webhosting companies that allow Python? I never used Python before, only PHP, and not sure how it works? Is there like a "xampp" for python? | How should I go about learning Python? | 0.019997 | 0 | 0 | 2,771 |
2,877,101 | 2010-05-20T19:27:00.000 | 3 | 0 | 0 | 0 | python,django,web-services,pylons | 2,877,686 | 3 | false | 1 | 0 | Yes, we use it directly. We have view functions that respond to some URI's with serialized JSON or XML objects instead of pretty HTML pages. | 2 | 2 | 0 | My friend said, "Pylons is so much better for web services."
My other friend said, "You can modify Django in a way to do exactly whatever you like."
In Django, what is necessary to be modified (urls.py? models classes? settings?) in order to do "web services" with APIs and REST and versioning, etc etc.? | Can Django be used for web services? | 0.197375 | 0 | 0 | 2,678 |
2,877,101 | 2010-05-20T19:27:00.000 | 2 | 0 | 0 | 0 | python,django,web-services,pylons | 30,111,944 | 3 | false | 1 | 0 | Absolutely.
Django is in fact made to be used on server side. But first you need to understand that it is a framework.
A framework is a set of tools which get the common activities done in web development (e.g Login or Sign up module). | 2 | 2 | 0 | My friend said, "Pylons is so much better for web services."
My other friend said, "You can modify Django in a way to do exactly whatever you like."
In Django, what is necessary to be modified (urls.py? models classes? settings?) in order to do "web services" with APIs and REST and versioning, etc etc.? | Can Django be used for web services? | 0.132549 | 0 | 0 | 2,678 |
2,877,617 | 2010-05-20T20:38:00.000 | 4 | 0 | 1 | 0 | python | 2,877,637 | 2 | true | 1 | 0 | Instead of using a list, why not use a dictionary and use small integers as the keys? Adding and removing items from the dictionary will not change the indices into the dictionary. You will want to keep one value in the dictionary that lets you know what the next assigned index will be. | 2 | 2 | 0 | I'm using python for my shopping cart class which has a list of items. When a customer wants to edit an item, I need to pass the JavaScript front-end some way to refer to the item so that it can call AJAX methods to manipulate it.
Basically, I need a simple way to point to a particular item that isn't its index, and isn't a reference to the object itself.
I can't use an index, because another item in the list might be added or removed while the identifier is "held" by the front end. If I were to pass the index forward, if an item got deleted from the list then that index wouldn't point to the right object.
One solution seems to be to use UUIDs, but that seems particularly heavyweight for a very small list. What's the simplest/best way to do this? | Referring to objects inside a list without using references or indices | 1.2 | 0 | 0 | 190 |
2,877,617 | 2010-05-20T20:38:00.000 | 2 | 0 | 1 | 0 | python | 2,877,644 | 2 | false | 1 | 0 | A UUID seems perfect for this. Why don't you want to do that?
Do the items have any sort of product_id? Can the shopping cart have more than one of the same product_id, or does it store a quantity? What I'm getting at is: If product_id's in the cart are unique, you can just use that. | 2 | 2 | 0 | I'm using python for my shopping cart class which has a list of items. When a customer wants to edit an item, I need to pass the JavaScript front-end some way to refer to the item so that it can call AJAX methods to manipulate it.
Basically, I need a simple way to point to a particular item that isn't its index, and isn't a reference to the object itself.
I can't use an index, because another item in the list might be added or removed while the identifier is "held" by the front end. If I were to pass the index forward, if an item got deleted from the list then that index wouldn't point to the right object.
One solution seems to be to use UUIDs, but that seems particularly heavyweight for a very small list. What's the simplest/best way to do this? | Referring to objects inside a list without using references or indices | 0.197375 | 0 | 0 | 190 |
2,878,081 | 2010-05-20T21:43:00.000 | 0 | 0 | 1 | 0 | python,chat,chatroom | 2,878,815 | 2 | false | 0 | 0 | Google AppEngine supports python provides scalable framework. Probably you'll save lots of time if you use it. | 1 | 1 | 0 | Hey guys, I have an idea that I'd like to start implementing that at the crux of it, will basically be a chat website, and will need to support multiple rooms. Quite frankly, I'm not too sure where to begin with regards to setting up a very sturdy/scalable chat system in python (or another language if you guys believe it to be a better alternative), so any suggestions that can get me pointed in the right direction will be greatly appreciated. | Scalable chat site in python | 0 | 0 | 0 | 365 |
2,878,474 | 2010-05-20T22:59:00.000 | 1 | 0 | 1 | 0 | python | 2,878,609 | 1 | false | 0 | 0 | If your function is looping through a lot of things, you could check the elapsed time during each iteration of the loop... but if it's blocked on something for the long period, then you need to have some other thread which can be handling the timing stuff while the thread you're timing is blocked. | 1 | 2 | 0 | Is there a way to have a function raise an error if it takes longer than a certain amount of time to return? I want to do this without using signal (because I am not in the main thread) or by spawning more threads, which is cumbersome. | Python: set a function timeout without using signal or threads? | 0.197375 | 0 | 0 | 702 |
2,879,008 | 2010-05-21T01:18:00.000 | 0 | 1 | 0 | 1 | python,ide | 11,520,785 | 2 | false | 0 | 0 | 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. | 1 | 3 | 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 | Python 3.0 IDE - Komodo and Eclipse both flaky? | 0 | 0 | 0 | 584 |
2,879,246 | 2010-05-21T02:34:00.000 | 1 | 0 | 0 | 0 | python,django,postgresql,psycopg2 | 14,780,956 | 4 | false | 0 | 0 | In my case, I had to reinstall libpq5. | 2 | 0 | 0 | I am trying to install postgrepsql to cygwin on a windows 7 machine and want it to work with django.
After built and installed postgrepsql in cygwin, I built and installed psycopg2 in cygwin as well and got no error, but when use it in python with cygwin, I got the "no such process" error:
import psycopg2
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.5/site-packages/psycopg2/init.py", line 60, in
from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: No such process
any clues?
Thanks!
Jerry | psycopg2 on cygwin: no such process | 0.049958 | 1 | 0 | 1,204 |
2,879,246 | 2010-05-21T02:34:00.000 | 0 | 0 | 0 | 0 | python,django,postgresql,psycopg2 | 2,885,759 | 4 | false | 0 | 0 | Why? There is native psycopg2 for Win. | 2 | 0 | 0 | I am trying to install postgrepsql to cygwin on a windows 7 machine and want it to work with django.
After built and installed postgrepsql in cygwin, I built and installed psycopg2 in cygwin as well and got no error, but when use it in python with cygwin, I got the "no such process" error:
import psycopg2
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.5/site-packages/psycopg2/init.py", line 60, in
from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: No such process
any clues?
Thanks!
Jerry | psycopg2 on cygwin: no such process | 0 | 1 | 0 | 1,204 |
2,879,251 | 2010-05-21T02:36:00.000 | 3 | 0 | 0 | 0 | asp.net,python,asp.net-mvc,django | 2,879,295 | 2 | false | 1 | 0 | ASP.NET MVC is pretty cool if you already know C# and/or ASP... but if you're starting from scratch, Django is (IMO) a better bet. You probably have more hosting options for Django, for one thing. | 1 | 7 | 0 | I am fairly new at web development scene, and I was wondering if you can help me break up the pros and cons of using python django vs asp.net mvc besides the maturity level of its framework.
I have intermediate experience with Java. As of right now, I am leaning towards Python, but I just wanted to make sure, I am making the right choice. I find myself limited with books available on asp.net web developments. I am aware that there is the storefront example on the official asp.net site. However, that tutorial was a little hard for me to follow. I've done a research around and was hoping python could be my next available choice. There are more tutorials available online for Python anyways.
What do you think? | Python Django vs ASP.NET MVC | 0.291313 | 0 | 0 | 9,471 |
2,880,316 | 2010-05-21T07:37:00.000 | 3 | 0 | 0 | 1 | python,wxpython,cx-freeze | 2,881,979 | 4 | false | 0 | 1 | If you're using Windows, you could rename your "main" script's extension (that launches the app) to .pyw | 1 | 31 | 0 | I'm developing a Python application using wxPython and freezing it using cxFreeze. All seems to be going fine apart from this following bit:
When I run the executable created by cxFreeze, a blank console window pops up. I don't want to show it. Is there any way I could hide it?
It doesn't seem to be documented on the cxFreeze site and Googling didn't turn up much apart from some similar sorta problems with Py2Exe.
Thanks. | How can I hide the console window when freezing wxPython applications with cxFreeze? | 0.148885 | 0 | 0 | 18,074 |
2,881,526 | 2010-05-21T11:15:00.000 | 2 | 0 | 1 | 0 | java,python,late-binding,compiled | 2,883,449 | 5 | false | 0 | 0 | I think the common misconception that Python is interpreted while Java is compiled arises because Java has an explicit compilation step - you have to run javac to convert your .java source file into a .class bytecode file that can be run.
As you rightly point out Python similarly compiles source files into bytecode but it does it transparently - compiling and running is generally done in a single step so it is less obvious to the user.
The important difference is between early & late binding and dynamic & static typing. The compiled/interpreted distinction is meaningless and irrelevant. | 3 | 13 | 0 | Python is compiled into an intermediate bytecode(pyc) and then executed. So, there is a compilation followed by interpretation. However, long-time Python users say that Python is a "late-binding" language and that it should`nt be referred to as an interpreted language.
How would Python be different from another interpreted language?
Could you tell me what "late-binding" means, in the Python context?
Java is another language which first has source code compiled into bytecode and then interpreted into bytecode.
Is Java an interpreted/compiled language?
How is it different from Python in terms of compilation/execution?
Java is said to not have, "late-binding". Does this have anything to do with Java programs being slighly faster than Python?
It'd be great if you could also give me links to places where people have already discussed this; i'd love to read more on this. Thank you. | Interpreted vs. Compiled vs. Late-Binding | 0.07983 | 0 | 0 | 1,865 |
2,881,526 | 2010-05-21T11:15:00.000 | 3 | 0 | 1 | 0 | java,python,late-binding,compiled | 2,881,732 | 5 | false | 0 | 0 | There's a connection between what we call the binding time and the concept of interpretation/compilation.
The binding time is the time when a symbolic expression is bound to its concrete value. That's more related to the definition of programming language, e.g. dynamic vs. static scoping of variables. Or static method vs. virtual methods or dynamic typing vs. static typing.
Then comes the implementation of the language. The more information are statically known upfront, the easier it is to write a compiler. Inversely, the more late bound the language is, the harder it is. Hence the need to rely on interpretive techniques sometimes.
The distinction between both isn't strict however. Not only can we consider that everything is ultimately interpreted (see S.Lott answer), but part of the code can be compiled, decompile, or recompile dynamically (e.g. JIT) making the distinction very fuzzy.
For instance, dynamic class loading in Java goes in the category "late binding": the set of class is not fixed once for all, and classes can be loaded dynamically. Some optimizations can be done when we know the set of classes, but will need to be invalidated once a new classes is loaded. The same happens with the ability to update a method with the debugging infrastructure: the JVM will need to de-optimize all call sites were the method had been inlined.
I don't know much about Python, but Python practitioners prefer maybe the term "late bound" to avoid such confusion. | 3 | 13 | 0 | Python is compiled into an intermediate bytecode(pyc) and then executed. So, there is a compilation followed by interpretation. However, long-time Python users say that Python is a "late-binding" language and that it should`nt be referred to as an interpreted language.
How would Python be different from another interpreted language?
Could you tell me what "late-binding" means, in the Python context?
Java is another language which first has source code compiled into bytecode and then interpreted into bytecode.
Is Java an interpreted/compiled language?
How is it different from Python in terms of compilation/execution?
Java is said to not have, "late-binding". Does this have anything to do with Java programs being slighly faster than Python?
It'd be great if you could also give me links to places where people have already discussed this; i'd love to read more on this. Thank you. | Interpreted vs. Compiled vs. Late-Binding | 0.119427 | 0 | 0 | 1,865 |
2,881,526 | 2010-05-21T11:15:00.000 | 7 | 0 | 1 | 0 | java,python,late-binding,compiled | 2,881,574 | 5 | true | 0 | 0 | Late binding is a very different concept to interpretation.
Strictly speaking, an interpreted language is executed directly from source. It doesn't go through a byte-code compilation stage. The confusion arises because the python program is an interpreter, but it interprets the byte-code, so it is Python's byte-code language that you would describe as "interpreted". The Python language itself is a compiled language.
Java bytecode, in contrast, is both interpreted and compiled, these days. It is compiled into native code by a JIT-compiler and then run directly on the hardware.
Late binding is a property of the type system and is present in most languages to some degree, regardless of whether they are interpreted or compiled. | 3 | 13 | 0 | Python is compiled into an intermediate bytecode(pyc) and then executed. So, there is a compilation followed by interpretation. However, long-time Python users say that Python is a "late-binding" language and that it should`nt be referred to as an interpreted language.
How would Python be different from another interpreted language?
Could you tell me what "late-binding" means, in the Python context?
Java is another language which first has source code compiled into bytecode and then interpreted into bytecode.
Is Java an interpreted/compiled language?
How is it different from Python in terms of compilation/execution?
Java is said to not have, "late-binding". Does this have anything to do with Java programs being slighly faster than Python?
It'd be great if you could also give me links to places where people have already discussed this; i'd love to read more on this. Thank you. | Interpreted vs. Compiled vs. Late-Binding | 1.2 | 0 | 0 | 1,865 |
2,881,825 | 2010-05-21T12:02:00.000 | 1 | 0 | 0 | 0 | java,php,python,django,symfony1 | 2,881,839 | 3 | false | 1 | 0 | I suppose the closest thing in Javaland is the venerable Web Application Archive (war file). | 1 | 3 | 0 | in symfony 2.0 and django there are bundles that contain everything for a feature (html, css, js, img, php/python).
so if you want to delete one feature, you basically just delete that bundle and unregister it from "main".
are there java frameworks for this too? or is it different in java cause java is a compiling language.
thanks | bundles in java? | 0.066568 | 0 | 0 | 110 |
2,882,060 | 2010-05-21T12:38:00.000 | 0 | 0 | 0 | 0 | python,user-interface,tkinter,frame,sliding | 2,896,537 | 1 | true | 0 | 1 | How you do it depends on the geometry manager, but the basic idea is simply to set the width of the frame to smaller and smaller values until it has a width of zero. You don't need a loop though -- the code is already running in the event loop, so take advantage of that. Use 'after' to schedule a job that changes the width a tiny bit, then reschedules itself for a few milliseconds later. | 1 | 0 | 0 | I am trying really hard to make a sliding frame containing widgets in tkinter in python. There is this frame inside a big window with different widgets. And as soon as i click on the next button on that frame the frame should slowly slide towards the left and vanish ultimately. As soon as it vanishes, i want new frame with widgets to come sliding towards right.
What should i do?
Anticipating your suggestions and ideas. | Creating a sliding frame containing widgets in tkinter in python | 1.2 | 0 | 0 | 1,113 |
2,882,448 | 2010-05-21T13:29:00.000 | 1 | 0 | 0 | 0 | python,console,chat,interrupt | 2,882,475 | 2 | true | 0 | 0 | Using select.select() on sys.stdin will allow you to check if a key has been pressed at the terminal. | 1 | 0 | 0 | I am writing python chatbot that displays output through console. Every half second it asks server for updates, and responds to message. In the console I can see chat log.
This is sufficient in most cases, however, sometimes I want to interrupt normal workflow and write custom chat answer myself. I would love to be able to press a button (or combination) that would switch to "custom reply mode". What is the best way to do that, or achieve similar result?
Thanks a lot! | Python - react to custom keyboard interrupt | 1.2 | 0 | 0 | 1,772 |
2,882,549 | 2010-05-21T13:44:00.000 | 0 | 0 | 0 | 0 | python,html,rss | 2,883,114 | 2 | true | 1 | 0 | Filetypes should generally be determined out-of-band. eg. if you are fetching the file from a web server, the place to look would be the Content-Type header of the HTTP response. If you're fetching a local file, the filesystem would have a way of determining filetype—on Windows that'd be looking at the file extension.
If none of that is available, you'd have to resort to content sniffing. This is never wholly reliable, and RSS is particularly annoying because there are multiple incompatible versions of it, but about the best you could do would probably be:
Attempt to parse the content with an XML parser. If it fails, the content isn't well-formed XML so can't be RSS.
Look at the document.documentElement.namespaceURI. If it's http://www.w3.org/1999/xhtml, you've got XHTML. If it's http://www.w3.org/1999/02/22-rdf-syntax-ns#, you've got RSS (of one flavour).
If the document.documentElement.tagName is rss, you've got RSS (of a slightly different flavour).
If the file couldn't be parsed as XML, it could well be HTML (or some tag-soup approximation of it). It's conceivable it might also be broken RSS. In that case most feed tools would reject it. If you need to still detect this case you'd be reduced to looking for strings like <html or <rss or <rdf:RSS near the start of the file. This would be even more unreliable. | 2 | 1 | 0 | Is there a function or method I could call in Python
That would tell me if the data is RSS or HTML? | Identifying if a data is RSS or HTML on python | 1.2 | 0 | 1 | 81 |
2,882,549 | 2010-05-21T13:44:00.000 | 2 | 0 | 0 | 0 | python,html,rss | 2,882,574 | 2 | false | 1 | 0 | You could always analyze it yourself to search for an xml tag (for RSS) or html tag (for HTML). | 2 | 1 | 0 | Is there a function or method I could call in Python
That would tell me if the data is RSS or HTML? | Identifying if a data is RSS or HTML on python | 0.197375 | 0 | 1 | 81 |
2,884,579 | 2010-05-21T18:29:00.000 | 3 | 0 | 0 | 1 | python,google-app-engine,httpwebrequest,scheduled-tasks | 2,889,352 | 3 | false | 1 | 0 | A task is removed from the queue when it executes if and only if it returns an HTTP 200 response. For any other response, it will be retried until it successfully executes.
As David's answer indicates, they can also be manually removed. | 1 | 3 | 0 | How can I remove a task from a task queue? Is Google App Engine Task Queue removes the task from the queue after it is executed? | Google App Engine, Task Queues | 0.197375 | 0 | 0 | 1,032 |
2,885,057 | 2010-05-21T19:38:00.000 | -1 | 0 | 1 | 1 | python,image,google-app-engine | 2,885,231 | 5 | false | 1 | 0 | How did you install PIL? If I remember correctly, I had to install it via MacPorts to get the App Engine SDK to recognize that it was installed.
You should probably install Python 2.5 and use that, while you're at it, since that is the Python version that App Engine uses and developing against 2.6 locally could potentially lead to surprising issues when you deploy your app. | 4 | 3 | 0 | I am using OS X 1.6 snow leopard and I successfully got PIL installed. I am able to open terminal and type import Image without any errors.
However, When using app engine I get Image error still saying that PIL is not installed. I am wondering if any of you have an thoughts as to how I can resolve this issue.
-Matthew | Python 2.6 + PIL + Google App Engine issue | -0.039979 | 0 | 0 | 1,343 |
2,885,057 | 2010-05-21T19:38:00.000 | 0 | 0 | 1 | 1 | python,image,google-app-engine | 2,889,386 | 5 | false | 1 | 0 | You cannot use PIL with Appengine; it uses C extensions and won't run in the sandbox environment. You do need to have PIL installed on your local machine to use the images API in dev_appserver, because the SDK version of the images API itself uses PIL, but this doesn't mean you can use all of PIL through the images API; the images API is fairly limited.
Additionally, it's a good idea to use Python 2.5 for development, as the production environment uses version 2.5.2 and not all Python 2.6 syntax will work in production (notably "except FooError as bar"), and the purpose of the development server is to test that your code will work right in production. | 4 | 3 | 0 | I am using OS X 1.6 snow leopard and I successfully got PIL installed. I am able to open terminal and type import Image without any errors.
However, When using app engine I get Image error still saying that PIL is not installed. I am wondering if any of you have an thoughts as to how I can resolve this issue.
-Matthew | Python 2.6 + PIL + Google App Engine issue | 0 | 0 | 0 | 1,343 |
2,885,057 | 2010-05-21T19:38:00.000 | 1 | 0 | 1 | 1 | python,image,google-app-engine | 4,180,349 | 5 | false | 1 | 0 | I had this same problem and found in GoogleAppEngineLauncher | Preferences that I needed to set the Python Path to /usr/local/bin/python2.5
After I did that it started working. | 4 | 3 | 0 | I am using OS X 1.6 snow leopard and I successfully got PIL installed. I am able to open terminal and type import Image without any errors.
However, When using app engine I get Image error still saying that PIL is not installed. I am wondering if any of you have an thoughts as to how I can resolve this issue.
-Matthew | Python 2.6 + PIL + Google App Engine issue | 0.039979 | 0 | 0 | 1,343 |
2,885,057 | 2010-05-21T19:38:00.000 | 0 | 0 | 1 | 1 | python,image,google-app-engine | 28,392,607 | 5 | false | 1 | 0 | What David Scott said is actually correct.
I had the errors blow running and couldn't for the heck of me couldn't resolve the issue no matter what patches I tried. What worked for me apparently, was simply changing the Python directory found on C:\python27_x64 and target the pythonw.exe file using the Google App Engine.
FYI, I run with Windows 8.1
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\appcfg.py", line 127, in
run_file(file, globals())
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\appcfg.py", line 123, in run_file
execfile(_PATHS.script_file(script_name), globals_)
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\appcfg.py", line 5399, in
main(sys.argv)
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\appcfg.py", line 5390, in main
result = AppCfgApp(argv).Run()
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\appcfg.py", line 2980, in Run
self.action(self)
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\appcfg.py", line 5046, in call
return method()
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\appcfg.py", line 3793, in Update
self._UpdateWithParsedAppYaml(appyaml, self.basepath)
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\appcfg.py", line 3814, in _UpdateWithParsedAppYaml
updatecheck.CheckForUpdates()
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\sdk_update_checker.py", line 243, in CheckForUpdates
runtime=runtime))
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\appengine_rpc.py", line 424, in Send
f = self.opener.open(req)
File "C:\Python27\lib\urllib2.py", line 431, in open
response = self._open(req, data)
File "C:\Python27\lib\urllib2.py", line 449, in _open
'_open', req)
File "C:\Python27\lib\urllib2.py", line 409, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 1240, in https_open
context=self._context)
TypeError: do_open() got an unexpected keyword argument 'context'
2015-02-08 17:42:53 (Process exited with code 1)
You can close this window now. | 4 | 3 | 0 | I am using OS X 1.6 snow leopard and I successfully got PIL installed. I am able to open terminal and type import Image without any errors.
However, When using app engine I get Image error still saying that PIL is not installed. I am wondering if any of you have an thoughts as to how I can resolve this issue.
-Matthew | Python 2.6 + PIL + Google App Engine issue | 0 | 0 | 0 | 1,343 |
2,885,822 | 2010-05-21T21:49:00.000 | 1 | 1 | 0 | 1 | java,c++,python,logging | 2,926,570 | 3 | false | 1 | 0 | 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. | 1 | 11 | 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! | Which logging library to use for cross-language (Java, C++, Python) system | 0.066568 | 0 | 0 | 2,806 |
2,886,048 | 2010-05-21T22:37:00.000 | 1 | 0 | 1 | 0 | python,coding-style,methods | 2,886,277 | 6 | false | 0 | 0 | You should use the same name when it means the same thing. For example, if you have a database of "cars", you might want to use the name "car" to refer to a single car in every method or function that accepts a car as an argument or works with car objects internally. Doing this, someone reading the code will begin to say to themselves "ok, this is a car" rather than "hmmm, I wonder what type of thing 'foo' is ...".
So, be consistent in using variable names, and that means you can use the same name many times as long as it has the same meaning. If at all possible, never use the same name to mean two different things. For example, don't use "item" to mean a car in one context and a random item from a list in another. | 5 | 2 | 0 | I'm thinking that the answer is probably 'no' if the program is small and there are a lot of methods, but what about in a larger program? If I am going to be using one variable in multiple methods throughout the program, is it smarter to:
Come up with a different phrasing for each method (to eliminate naming conflicts).
Use the same name for each method (to eliminate confusion)
Just use a global variable (to eliminate both)
This is more of a stylistic question than anything else. What naming convention do YOU use when passing variables? | Python: When passing variables between methods, is it necessary to assign it a new name? | 0.033321 | 0 | 0 | 700 |
2,886,048 | 2010-05-21T22:37:00.000 | 1 | 0 | 1 | 0 | python,coding-style,methods | 2,887,417 | 6 | false | 0 | 0 | There's no such requirement to give variables different names in different methods or function arguments. In fact, it would greatly hurt readability and go against common sense -- when two things are the same, one tries to give them the same name, not different ones. | 5 | 2 | 0 | I'm thinking that the answer is probably 'no' if the program is small and there are a lot of methods, but what about in a larger program? If I am going to be using one variable in multiple methods throughout the program, is it smarter to:
Come up with a different phrasing for each method (to eliminate naming conflicts).
Use the same name for each method (to eliminate confusion)
Just use a global variable (to eliminate both)
This is more of a stylistic question than anything else. What naming convention do YOU use when passing variables? | Python: When passing variables between methods, is it necessary to assign it a new name? | 0.033321 | 0 | 0 | 700 |
2,886,048 | 2010-05-21T22:37:00.000 | 1 | 0 | 1 | 0 | python,coding-style,methods | 2,886,240 | 6 | false | 0 | 0 | Don't go inventing ways of indicating which method the name belongs to. If you are coding correctly you will won't be treating other methods variables as local. If you have a hanle on method foobar and want its foo value use foobar.foo.
Variable names should indicate contents of the variable and aid in understanding the code. Referring to a foo by a lot of different names because a lot of methods use foos won't help. Your time may be better spent clarifying cases where a foo here is not a foo there. For those cases you problably need to use different terminology in at least one case. Document the case in your code.
Using the same name for the variable will help tracing where you use key objects in your code. You will also have a lot of generic variables which make code easier to understand: i, j, and k for interators; result for result for intermediate results; etc. | 5 | 2 | 0 | I'm thinking that the answer is probably 'no' if the program is small and there are a lot of methods, but what about in a larger program? If I am going to be using one variable in multiple methods throughout the program, is it smarter to:
Come up with a different phrasing for each method (to eliminate naming conflicts).
Use the same name for each method (to eliminate confusion)
Just use a global variable (to eliminate both)
This is more of a stylistic question than anything else. What naming convention do YOU use when passing variables? | Python: When passing variables between methods, is it necessary to assign it a new name? | 0.033321 | 0 | 0 | 700 |
2,886,048 | 2010-05-21T22:37:00.000 | 2 | 0 | 1 | 0 | python,coding-style,methods | 2,886,210 | 6 | false | 0 | 0 | Python's scoping rules pretty much free you from the need to use different or identical names for variables just to satisfy language needs.
Variable name choice should be driven primarily by readability and maintainability concerns. In general, it is good to use just one name to identify a particular kind of thing throughout the code. This kind of consistency is helpful to readers. Naming variables, methods, and classes is one of the biggest tools you have to make your intent clear---to both yourself and others.
There is a large (and not entirely consistent) literature about naming things. A couple of things to consider:
Names with small scopes can be short names that do not necessarily tell the whole story about the variable, since the entire context for the variable is easily visible. i,j,k as counters in loops are maybe the classic example---but you don't see that much in Python with its dandy for item in collection loop construct.
The flip side of this is that names with larger scopes (instance variables in a class, maybe) should have more completely descriptive names, since they show up in places where the initialization/modification context is not visible.
Try not to put 'noise' pieces into your names. frequencyInfo---what, exactly does the Info part add to things?
Don't include the data structure type in the name---the dict in urldict doesn't really help you much.
Use names from the domain you are working in when you can, but don't force it.
Python style leans towards terse names. Careful thinking and choices often result in a name that is brief, but apt. | 5 | 2 | 0 | I'm thinking that the answer is probably 'no' if the program is small and there are a lot of methods, but what about in a larger program? If I am going to be using one variable in multiple methods throughout the program, is it smarter to:
Come up with a different phrasing for each method (to eliminate naming conflicts).
Use the same name for each method (to eliminate confusion)
Just use a global variable (to eliminate both)
This is more of a stylistic question than anything else. What naming convention do YOU use when passing variables? | Python: When passing variables between methods, is it necessary to assign it a new name? | 0.066568 | 0 | 0 | 700 |
2,886,048 | 2010-05-21T22:37:00.000 | 3 | 0 | 1 | 0 | python,coding-style,methods | 2,886,109 | 6 | false | 0 | 0 | I tend to reuse variable names in local functions a lot, as long as they are mid-process. Usually 'result' for a db lookup or a calculation that is used intermediary and is needed to generate or construct the end-result of the method.
Only rarely have I used global variables, in fact only if I must. | 5 | 2 | 0 | I'm thinking that the answer is probably 'no' if the program is small and there are a lot of methods, but what about in a larger program? If I am going to be using one variable in multiple methods throughout the program, is it smarter to:
Come up with a different phrasing for each method (to eliminate naming conflicts).
Use the same name for each method (to eliminate confusion)
Just use a global variable (to eliminate both)
This is more of a stylistic question than anything else. What naming convention do YOU use when passing variables? | Python: When passing variables between methods, is it necessary to assign it a new name? | 0.099668 | 0 | 0 | 700 |
2,886,466 | 2010-05-22T00:47:00.000 | 0 | 0 | 0 | 0 | python,django,cgi,web-frameworks | 2,886,479 | 4 | false | 1 | 0 | A web application framework is independent of the actual HTTP server in use. The server passes an application written using it the requests, and it cranks some gears and spits out a response, which is sent back to the HTTP server.
Django has 3 popular connectors to the HTTP server: WSGI, FastCGI, and mod_python. These are all explained... somewhere here, so I'll not repeat information that can easily be discovered. | 3 | 3 | 0 | I'm getting into python for cgi and came across Django. I'm not quite sure I understand it very much. Is it something I have to install inside apache or is it just something I can use with my cgi?
Wanted to know because I'd love to learn it but my server I'm using doesn't give me a lot of privileges.
thanks | What exactly is a web application framework? | 0 | 0 | 0 | 474 |
2,886,466 | 2010-05-22T00:47:00.000 | 0 | 0 | 0 | 0 | python,django,cgi,web-frameworks | 2,888,049 | 4 | false | 1 | 0 | Basically the functions of any framework are:-
make sure that you do not have to do the repetitive tasks.
make it easy for you to re-use and modularize
they provide a layer of abstraction(which in most cases, makes you more productive)
So, Django is a web application framework; naturally it satisfies all three conditions above.
If you are interested in cgi programming using Python you should`nt be looking at Django.
On the other hand, if you are looking for options for web-development, then django certainly is a good option while manual cgi programming is not. | 3 | 3 | 0 | I'm getting into python for cgi and came across Django. I'm not quite sure I understand it very much. Is it something I have to install inside apache or is it just something I can use with my cgi?
Wanted to know because I'd love to learn it but my server I'm using doesn't give me a lot of privileges.
thanks | What exactly is a web application framework? | 0 | 0 | 0 | 474 |
2,886,466 | 2010-05-22T00:47:00.000 | 0 | 0 | 0 | 0 | python,django,cgi,web-frameworks | 2,886,475 | 4 | false | 1 | 0 | A web application framework like Django replaces CGI by spawning its own processes and handling requests from a web server. They also provide tools for simplifying html by creating templates, partial templates, helpers etc.
If you don't have full control over your server, your host will need to install it for you. | 3 | 3 | 0 | I'm getting into python for cgi and came across Django. I'm not quite sure I understand it very much. Is it something I have to install inside apache or is it just something I can use with my cgi?
Wanted to know because I'd love to learn it but my server I'm using doesn't give me a lot of privileges.
thanks | What exactly is a web application framework? | 0 | 0 | 0 | 474 |
2,887,045 | 2010-05-22T05:20:00.000 | 9 | 0 | 0 | 0 | django,vb6,python | 2,887,309 | 1 | true | 1 | 0 | If your definition of barcode functionality is the ability to read and write barcodes, you should keep in mind two things.
Barcodes are actually read by barcode readers, and from the computers' point of view they are just input devices, just like keyboards. When the reader reads a barcode, it just "types" it in, character by character. Usually it's configurable what the reader sends after the code, tab or enter are quite common options. Enter is the easiest to deal with.
There's nothing special in writing barcodes, it's just text with a special font, with *-characters before and after the code.
Handling barcodes doesn't really have much to do with Django. Some tricks are required to get it done within browsers, but these would apply if you were doing it in RoR, .net or whatever:
Handling barcodes from a web app is quite straightforward. A text input is needed and a bit of javascript to make sure the input has focus, and to trigger action when a barcode has been read.
Printing barcodes is not very hard either, just use css3 embedded fonts. If that's too cutting edge, you can always create images of the barcodes server-side, and it'll work with any browser. | 1 | 5 | 0 | I am in process of converting Visual Basic app into Python Django. Currently, it has barcode functionality to process sales at a store. Can this be achieved with python django. | Django Barcode for store sales | 1.2 | 0 | 0 | 2,820 |
2,888,035 | 2010-05-22T12:18:00.000 | 4 | 1 | 1 | 0 | python | 2,888,059 | 4 | false | 0 | 0 | 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. | 3 | 0 | 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. | information hiding in python | 0.197375 | 0 | 0 | 5,646 |
2,888,035 | 2010-05-22T12:18:00.000 | 4 | 1 | 1 | 0 | python | 2,888,071 | 4 | false | 0 | 0 | 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. | 3 | 0 | 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. | information hiding in python | 0.197375 | 0 | 0 | 5,646 |
2,888,035 | 2010-05-22T12:18:00.000 | 2 | 1 | 1 | 0 | python | 2,888,448 | 4 | false | 0 | 0 | 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. | 3 | 0 | 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. | information hiding in python | 0.099668 | 0 | 0 | 5,646 |
2,888,468 | 2010-05-22T14:36:00.000 | 6 | 1 | 0 | 0 | java,python,huffman-code | 2,888,480 | 3 | false | 1 | 0 | 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. | 2 | 3 | 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? | Huffman coding two characters as one | 1 | 0 | 0 | 1,395 |
2,888,468 | 2010-05-22T14:36:00.000 | 0 | 1 | 0 | 0 | java,python,huffman-code | 2,888,494 | 3 | false | 1 | 0 | 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. | 2 | 3 | 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? | Huffman coding two characters as one | 0 | 0 | 0 | 1,395 |
2,889,255 | 2010-05-22T18:27:00.000 | 0 | 0 | 0 | 0 | python,wxpython | 2,893,253 | 8 | false | 0 | 1 | I don't think a wxFrame can return a value since it is not modal. If you don't need to use a wxFrame, then a modal dialog could work for you. If you really need a frame, I'd consider using a custom event.
It would go something like this:
(1) User clicks to close the wxFrame
(2) You override OnClose (or something like that) to pop up a dialog to ask the user a question
(3) Create and post the custom event
(4) Close the wxFrame
(5) Some other code processes your custom event | 1 | 7 | 0 | Could someone show me how I could return a value from a wxPython Frame? When the use clicks close, I popup a message dialog asking him a question. I would like to return the return code of this message dialog to my calling function.
Thanks | Return value from wxPython Frame | 0 | 0 | 0 | 7,486 |
2,889,490 | 2010-05-22T19:32:00.000 | 1 | 0 | 0 | 1 | python,nfs | 10,356,817 | 2 | false | 0 | 0 | you cat parse /proc/mount file. Notice, that on different platforms and kernel versions file format may be different. | 1 | 2 | 0 | I wrote a python script that depends on a certain NFS share to be available. If the NFS share is not mounted it will happily copy the files to the local path where it should be mounted, but fail later when it tries to copy some files back that were created on the NFS server.
I'd like to catch this error specifically so I can print a useful error message that will tell the users of this script what they have to do.
My first idea would be to execute mount using subprocess and then check the output for this nfs share. But I'm wondering if there isn't a nicer and more robust method of doing it. | Check if NFS share is mounted in python script | 0.099668 | 0 | 0 | 4,930 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.