Is there any article/paper on what features the Python language has to offer? Why should one go with Python instead of any other language? What are the strong and the weak points of Python?
I have a (python) list of strings which refer to python source files and subsequently classes within those files which I want to import and then create an instance of the classes within the files (everything follows a strict naming convention, making this theoretically possible), in Ruby I would do something like:
require "lib/sources/#{source}.rb"
s = source.constantize.new
How would I do something similar in Python?
Thanks,
Ben
We have server on Python and client + web service on Ruby. That works only if file from URL is less than 800 k. It seems like "socket.puts data" in a client works, but "output = socket.gets" - not. I think problem is in a Python part. For big files tests run "Connection reset by peer". Is it buffer size variable by default somewhere in a Python?
I am using Python 2.5. The Python logging module allows adding contextual information to your logging output. Is something similar possible in Python 2.5?
Hi
I'm currently running a Django project on my school's webserver with FCGI. I did follow the multiple guides that recommends installing a virtual local Python environment and it worked out great. The only issue i had was that "touching" my fcgi-file to reload source-files wasn't enough, but instead i had to kill the python service via SSH. This because mod_fcgid is used.
However, the admin didn't think it was a great idea that i ran my own local python. He thought it better if i just told him what modules to install on root, which was a pretty nice service really.
But doing this, i can no longer kill python since it's under root(though immoral as I am, I've definitely tried). The admins recommendation was that I should try too make the fcgi script reload itself by checking time stamp. I've tried to find documentation on how to do this, but fund very little and since I'm a absolute beginner i have no idea what would work.
Anyone have experience running python/django under mod_fcgid or tips on where to find related guides/documentation?
(Keep in mind I'm working in Python 3, so a solution needs to work in Python 3.)
I would like to use the copyreg module to teach Python how to pickle functions. When I tried to do it, the _Pickler object would still try to pickle functions using the save_global function. (Which doesn't work for unbound methods, and that's the motivation for doing this.)
It seems like _Pickler first tries to look in its own dispatch for the type of the object that you want to pickle before looking in copyreg.dispatch_table. I'm not sure if this is intentional.
Is there any way for me to tell Python to pickle functions with the reducer that I provide?
Python's urlparse function parses an url into six components (scheme, netloc, path and others stuff)
Now I've found that parsing "example.com/path/file.ext" return no netloc but a path "example.com/path/file.ext".
Should't it be netloc = "example.com" and path = "/path/file.ext"?
Do we really need a "://" to determine wether or not a netloc exists?
Python's ticket: http://bugs.python.org/issue8284
Hello!
Basically I have a script in Python that grabs the text from an open window using getWindowText() and outputs it to the screen. The python loops so as the text in the window changes, it outputs the changes, so the output of the python will always be up to date with the window text.
I'm trying to access this text in my Java program by executing the python script as a process and reading the text it outputs using a buffered reader.
For some reason this works fine for the first block of text, but will not read any more after this, it wont read any updates to the text as the python outputs it.
Can someone shed some light on this? I'm about to try and use Jython, but I'd really like to know what the problem is here...
try {
Runtime r = Runtime.getRuntime();
Process p = r.exec("cmd /c getText.py");
BufferedReader br = new BufferedReader(
new InputStreamReader(p.getInputStream()));
int line;
while (true) {
line = br.read();
System.out.print((char) line);
}
} catch (Exception e) {
e.printStackTrace();
}
hi.
Sorry to flood so many questions this week.
I assume thread index returned by thread.get_id is implementation specific.
In case of the pthreads, is index reused? IE, if thread 0 runs and joins, is thread launched afterwords going to have a different ID?
the reason I ask this is a need to implement Singleton pattern with a twist: each thread gets its own instance. I know it sounds very crazy, but threads control hardware (cuda) which does not permit device memory sharing.
What is a good way to implement such pattern?
I want to know how to use variables for objects and function names in Python. In PHP, you can do this:
$className = "MyClass";
$newObject = new $className();
How do you do this sort of thing in Python? Or, am I totally not appreciating some fundamental difference with Python, and if so, what is it?
I have a cURL call that I use in PHP:
curl -i -H 'Accept: application/xml' -u login:key "https://app.streamsend.com/emails"
I need a way to do the same thing in Python. Is there an alternative to cURL in Python. I know of urllib but I'm a Python noob and have no idea how to use it.
I'm working on a really simple python package for our internal use, and want to package it as a .egg file, and when it's installed/used I want it to access a text file that is placed in an appropriate place on the computer.
So where is the best place to put application data in python? (that is meant to be edited by users) How do I get my python package to automatically install a default file there?
I've been wanting to write a python script that would run several instances of rsync in sequence for backing up data to a different computer.
At the moment I just have this text file with the commands I use and I've just been copy-pasting them into the terminal, and it seems kinda silly.
I want to be able to use python to do this for me. I know very vaguely how to use subprocess.popen, but I have no clue how to get python to interact with rsync directly, like for entering my password for me. Can python do that?
Something like:
if theProccess.proccessResponse == "Password:" :
theProccess.respond(string)
Or is the best that I can do is just have it, or even a bash script, just run the rsyncs in sequence and have to type my password in over and over again?
Thanks in advance.
I am using Fedora 17 xfce and I am programming in Python 2.7.3. Fedora uses a package manager called yum. I have a python script that searches for packages like this:
import os
package = raw_input("Enter package name to search: ")
os.system("yum list " + package)
So I want python to check if in the output of this command exists the words "No matching packages to list". I checked a similar question and I tried some methods [http://stackoverflow.com/questions/2502833/python-store-output-of-subprocess-call-in-a-string][1]
but the string contained only the first line of the output.
Thanks in advance
I have recently started learning Python and I have 2 questions relating to modules.
Is there a way to obtain a list of Python modules available (i.e. installed) on a mchine?
I am using Ubuntum Karmic and Synaptic for package management. I have just installed a python module.Where is the module code actually stored on my machine? (is there a default [recommended] location that modules are stored)?
The title explains it well. I have set up Notepad++ to open the python script in the command prompt when I press F8 but all Swedish characters looks messed up when opening in CMD but perfectly fine in e.g IDLE.
This simple example code:
#!/usr/bin/env python
#-*- coding: UTF-8 -*-
print "åäö"
Looks like this.
As you can see the output of the bath file I use to open Python in cmd below shows the characthers correctly but not the python script above it. How do i fic this?
I once read about minimal python installation without a lot of the libraries that come with the python default installation but could not find it on the web...
What I want to do is to just pack a script with the python stuff required to execute it and make portable.
Does any one know about something like that?
Thanks
Trying to use something like the below with a char array but it doesn't compile. But the example with short[] works fine. Any idea why? :)
char someChars[] = {'s','h','e','r','r','y'};
BOOST_FOREACH(char& currentChar, someChars)
{
}
short array_short[] = { 1, 2, 3 };
BOOST_FOREACH( short & i, array_short )
{
++i;
}
i wonder if there are tutorials that go through the syntax differences for ruby and python?
i have seen a comparison between ruby and php but not between ruby and python.
i have looked at both ruby and python but it would be very useful with this side-by-side comparison for deciding which one to choose.
thanks
Not sure what to make of this error. Added -D_WIN32_WINNT=0x0501 to Visual Studio's "Command Line" options under Project Properties but it says it doesn't recognize it and the warning still appears.
I am also not sure how to add the Preprocessor Definition. :)
Thanks for any help!
1Please define _WIN32_WINNT or
_WIN32_WINDOWS appropriately. For example: 1- add -D_WIN32_WINNT=0x0501
to the compiler command line; or 1-
add _WIN32_WINNT=0x0501 to your
project's Preprocessor Definitions.