Hi guys, I had written a program in Python 3, but now want to convert it into Python 2 code. Are there any utilities to do that automatically?
Thanks, R
When I try to print a Unicode string in a windows console, I get a "UnicodeEncodeError: 'charmap' codec can't encode character ...." error. I assume this is because the Windows console does not accept Unicode-only characters. What's the best way around this? Is there any way I can make Python automatically print a "?" instead of failing in this situation?
Edit: I'm using Python 2.5.
I'd like to be able to post twitter messages from python 3.0. None of the twitter API I have looked at support python 3.1. Since the post proceedure only requires this :
JSON: curl -u username:password -d status="your message here" http://api.twitter.com/1/statuses/update.json
I was wondering if it is possible with the standard libraries to format this so a message could be sent. My head says it should be possible.
I'm writing a web app using Python and the web.py framework, and I need to use memcached throughout.
I've been searching the internet trying to find some good documentation on the python-memcached module, but all I could find was this example on the MySQL website, and the documentation on its methods isn't great.
Hi All,
I know that there is the PyObjC bridge is OSX and what I want to do is to put a python application/script in the rightclick context menu of OS X. there is the OnMyCommand plugin but I dont think that supports python. I've had a look at how to do it in Carbon/ Objective-C and i'll admit it im a wuss and am just not smart enough yet to grok how to do it (I aint even close to groking it actually.)
Anybody got any idea's on how I might go about this?
Cheers
I need a python script that will do the following:
connect to a URL, and that URL will return a number like 1200.
Use the number, to download xml files named: 1 to x where x is the number from #1.
store the files in a particular directory.
Sorry I've never written a python script, so if you could guide me along that would be great (maybe with a some comments).
I will be running this as a cron job if that matters.
Hi,
I want to tokenize a given mathematical expression into a binary tree like this:
((3 + 4 - 1) * 5 + 6 * -7) / 2
'/'
/ \
+ 2
/ \
* *
/ \ / \
- 5 6 -7
/ \
+ 1
/ \
3 4
Is there any pure Python way to do this? Like passing as a string to Python and then get back as a tree like mentioned above.
Thanks.
I want to declare an Array and all items present in the ListBox Should Be deleted irrespective of the Group name present in the ListBox. can any body help me coding in Python. I am using WINXP OS & Python 2.6.
If you look at the following line of python code:
bpy.ops.object.particle_system_add({"object":bpy.data.objects[2]})
you see that in the parameters there is something enclosed in braces. Can anyone tell me what the braces are for (generically anyway)? I haven't really seen this type of syntax in python and I can't find any documentation on it.
Any help is greatly appreciated. Thank you.
Looking to use FastLZ in Python, or something similar. Tried Google and didn't find anything. Wondering if there is another algorithm with similar performance available in Python?
Hey,
I'm new to python so I really don't know the language very well.
the following example was taken from here http://docs.python.org/library/json.html
>>> import json
>>> json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')
[u'foo', {u'bar': [u'baz', None, 1.0, 2]}]
what does the u mean? and how do i know which elements are available in the dictionary?
How can I write to files using Python (on Windows) and use the Unix end of line character?
e.g. When doing:
f = open('file.txt', 'w')
f.write('hello\n')
f.close()
Python automatically replaces \n with \r\n.
Hello. I have a Java app that takes pretty much time to be initialized (so I can't use command-line like interface) and I need to pass text and receive the output of a Java method from Python. Is it possible to load the Java application, have it opened all the time the Python script runs and use a method from that app?
How would you convert an integer to base 62 (like hexadecimal, but with these digits: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ').
I have been trying to find a good Python library for it, but they all seems to be occupied with converting strings. The Python base64 module only accepts strings and turns a single digit into four characters. I was looking for something akin to what URL shorteners use.
After reading http://stackoverflow.com/questions/635483/what-is-the-best-way-to-implement-nested-dictionaries-in-python why is it wrong to do:
c = collections.defaultdict(collections.defaultdict(int))
in python? I would think this would work to produce
{key:{key:1}}
or am I thinking about it wrong?
I'd like my Python script to read some data out of a postgresql dump file. The Python will be running on a system without postgresql, and needs to process the data in a dump file.
It looks fairly straightforward to parse the CREATE TABLE calls to find the column names, then the INSERT INTO rows to build the contents. But I'm sure there would be quite a few gotchas in doing this reliably. Does anyone know of a module which will do this?
I am attempting to to use python to gain some performance on a task that can be highly parallelized using http://docs.python.org/library/multiprocessing.
When looking at their library they say to use chunk size for very long iterables. Now, my iterable is not long, one of the dicts that it contains is huge: ~100000 entries, with tuples as keys and numpy arrays for values.
How would I set the chunksize to handle this and how can I transfer this data quickly?
Thank you.
What is the equivalent of the backticks found in Ruby and Perl in Python? That is, in Ruby I can do this:
foo = `cat /tmp/baz`
What does the equivalent statement look like in Python? I've tried os.system("cat /tmp/baz") but that puts the result to standard out and returns to me the error code of that operation.
What is the purpose of the 'self' word in python. I understand it refers to the specific object created from that class, but i cant see why it explicitly needs to be added to very function as a parameter. To illustrate, in ruby, i could do this:
class myClass
def myFunc(name)
@name = name
end
end
Which i understand, quite easily, However in python i need to include self:
class myClass:
def myFunc(self, name):
self.name = name
Can anyone talk me through this?
Any help would be appreciated.
I am using a shared hosting environment that will not give me access to the command line.
Can I download the python module on my computer, compile it using python setup.py installand then simply upload a .py file to the web host?
If yes, where does the install statement place the compiled file?
I need to create a large matrix (array) structure (3 axis) and each element should store the reference to a Python object (myclass instance). Is it possible to use numpy to create such an array. Which data type should I use in order to store Python references?
The advantage of numpy is the support of slicing at different levels. The alternativee is to create a nested (nested) list but it is a cumbersome solution.
hi ,
Mine is similar to this question.
http://stackoverflow.com/questions/2042342/network-path-and-variables-in-python/2042376
The only difference is my network drive has a password protect with user name and password .
I need to copy files to a samba share using python and verify it.
if i manually login in then the code works but without logging in the shutil command does not work
Thanks
I found this python plugin list but thought I'd ask if anyone has any experience with anything listed there?
I'm totally new to both python and dynamic programming languages if that makes any difference.
Is there a way to encrypt files (.zip, .doc, .exe, ... any type of file) with Python?
I've looked at a bunch of crypto libraries for Python including pycrypto and ezpycrypto but as far as I see they only offer string encryption.