Hi boys, im newest... I've got a simple question... wich is better? Python or C++? I wanna study computational science, and i like algorithms and TAD analyses... what do you prefer?
Hello,
How would I pass a Python variable to the Bash shell? It should work like this:
foo="./RetVar.py 42"
Replace the double-quotes with `s
I have tried printing and sys.exiting the result, but to no avail. How would I accomplish my goal?
In Perl, I would write:
$x = "abbbc";
$x =~ s/(b+)/z/;
print "Replaced $1 and ended up with $x\n";
# "Replaced bbb and ended up with azc"
How do I do this in Python -- do a regular-expression string replacement and record what it was that got replaced?
I'm writing a script to parse some text files, and insert the data that they contain into a mysql database. I don't have root access on the server that this script will run on. I've been looking at mysql-python, but it requires a bunch of dependencies that I don't have available. Is there a simpler way to do this?
I have a list of elements, and each element consists of four seperate values that are seperated by tabs:
['A\tB\tC\tD', 'Q\tW\tE\tR', etc.]
What I want is to create a larger list without the tabs, so that each value is a seperate element:
['A', 'B', 'C', 'D', 'Q', 'W', 'E', 'R', etc.]
How can I do that in Python? I need it for my coursework, due tonight (midnight GMT) and I'm completely stumped.
I am trying to add some security to my computer at home and would like to have a copy of all Yahoo! IMs sent to me. I am using Python 2.6 on Windows.
I would also like to have every URL in Internet Explorer sent to me.
I'm currently trying to build a scalable infrastructure for my Python webservers.
Actually, I'm trying to find the most elegant way to build a scalable cluster to host all my Python WebServices.
For now, I'm using three servers like this:
1 x PuppetMaster to deploy my servers.
2 x Apache Reverse Proxy Front-end servers.
1 x Apache HTTPd Server which host the Python WSGI Applications and binded to using mod_wsgi.
4 x MongoDB Clustered server.
Everything is OK concerning the Reverse proxy and the DB Backend, I'm able to easily add a new Reverse Proxy and a new DB Node, but my problem is about the Python WebServer.
I thinked to just provision a new node with exactly the same configuration and a rsync replication between the two nodes, but It's not really usefull in term of deployement for my developpers etc.
So if you have a solution which is as efficient and elegant that the Tomcat Cluster I'll be really happy to ear it ;-)
Its not urgent but I was just wondering how one would go about authenticating against a single db using python and openfire? Is there a simple module that will do this?
in python , suppose i have file data.txt . which has 6 lines of data . I want to calculate the no of lines which i am planning to do by going through each character and finding out the number of '\n' in the file . How to take one character input from the file ? Readline taken the whole line .
Python offers an optional else clause in loop statements, which is executed if and only if the loop is not terminated by a break. For an interesting discussion about this neglected commodity, see this question. Here, I just wanted to know:
if the very concept of this loop-else construct originates from another language (either theoretical or actually implemented),
conversely, if it was taken up in any newer language.
May be I should ask the former to Guido, but he surely is a too busy guy for such a futile inquiry. ;-)
I have a file that I need to "protect" so that it cannot be copied! I am using Python on Windows XP.
I think it may just be changing file permissions??
I was wondering how to make a python script portable to both linux and windows?
One problem I see is shebang. How to write the shebang so that the script can be run on both windows and linux?
Are there other problems besides shebang that I should know?
Is the solution same for perl script?
Thanks and regards!
All the Python built-ins are subclasses of object and I come across many user-defined classes which are too. Why? What is the purpose of the class object? It's just an empty class, right?
In a python source code I stumbled upon I've seen a small b before a string like in:
b"abcdef"
I know of u prefix that means unicode and r prefix that means raw.
What does the b stand for and in which kind of source code is it useful as it seems to be exactly like a plain string without any prefix ?
In Windows the Dropbox client uses python25.dll and the MS C runtime libraries (msvcp71.dll, etc). On OS X the Python code is compiled bytecode (pyc).
My guess is they are using a common library they have written then just have to use different hooks for the different platforms.
What method of development is this? It clearly isn't IronPython or PyObjC. This paradigm is so appealing to me, but my CS foo and Google foo are failing me.
Is there any IDE (like VS) with drag and drop support for building python GUI, connecting to dbs etc?
Eventhough I am an emacs guy, I find it much easier to create GUI with VS.
I am doing some prototyping for a new desktop app i am writing in Python, and i want to use SQLite and an ORM to store data.
My question is, are there any ORM libraries that support auto-generating/updating the database schema and work with SQLite?
I would like to install my python application as a command line tool that should work entirelly inside the install directory (for example C:\Python26\Lib\site-packages\application)
The problem is I would like to reffer in runtime to the submodules and resources from within the application directory three. If I install the app with [console_scripts] option the default path is the current directory. Is there a elegant way to keep the current execution path of the application to the site-packages directory?
Thanks
Although it does not seem possible, I wanted to put this out there to see if others had some innovative solutions to 'dynamically loading and executing code in python'
So if one saved code in a database, one could read it and 'exec it', however if one wanted to use it in a similar fashion to the filesystem, one would need to
'save and load the compiled .pyc'
create an 'import dbimp' ala 'import imp' etc.
any pointers? ideas? thoughts?
I have several python modules that I've written. Randomly, I used file on this directory, and I was really surprised by what I saw. Here's the resulting count of what it thought the files were:
1 ASCII Java program text, with very long lines
1 a /bin/env python script text executable
1 a python script text executable
2 ASCII C++ program text
4 ASCII English text
18 ASCII Java program text
That's strange! Any idea what's going on or why it seems to think python modules are very often java files?
I'm using CentOS 5.2.
My question really is can you do EVERYTHING in PHP that you can do in (Ruby)Rails/Django(python)? By me just concentrating on PHP (Framworks too) will i be losing out in someway? I prefer PHP but everyone tells me Rails is better?
Any advice?
Thank you in advance ;-)
Is there Perl's YAPE::Regex::Explain alternative to python?
For example, which could do following regex
\w+=\d+|\w+='[^']+'
to explanations like this
NODE EXPLANATION
--------------------------------------------------------------------------------
\w+ word characters (a-z, A-Z, 0-9, _) (1 or
more times (matching the most amount
possible))
--------------------------------------------------------------------------------
= '='
--------------------------------------------------------------------------------
\d+ digits (0-9) (1 or more times (matching
the most amount possible))
--------------------------------------------------------------------------------
| OR
--------------------------------------------------------------------------------
\w+ word characters (a-z, A-Z, 0-9, _) (1 or
more times (matching the most amount
possible))
--------------------------------------------------------------------------------
=' '=\''
--------------------------------------------------------------------------------
[^']+ any character except: ''' (1 or more times
(matching the most amount possible))
--------------------------------------------------------------------------------
' '\''
I am searching for a web toolkit that is
Python compatible
social/db/wiki like
google-appengine compatible
has built in pagination
handles 'relationships' between entities
uses ajax
modal dialogs
but degrades very gracefully on browsers that dont have js
good ui decisions that make it gracefully degrade even on mobile, text and braille/speech interfaces.
The following unicode and string can exist on their own if defined explicitly:
>>> value_str='Andr\xc3\xa9'
>>> value_uni=u'Andr\xc3\xa9'
If I only have u'Andr\xc3\xa9' assigned to a variable like above, how do I convert it to 'Andr\xc3\xa9' in Python 2.5 or 2.6?