text
stringlengths
226
34.5k
Tkinter: Changing a variable within a function Question: I know this kind of question gets asked all the time but either i've been unable to come across the answer i need, or i've been unable to understand it when i did. I want to be able to do something like: spam = StringVar() spam.set(aValue) ...
Different styles for Windows forms in Ironpython Question: I want to change the look of my Ironpython windows forms, Is it possible to change the style of the form and for example make it more like a Mac? thank you Answer: As an interface designer, it's important to use an many standard windows controls as possible....
Write to UTF-8 file in Python Question: I'm really confused with the `codecs.open function`. When I do: file = codecs.open("temp", "w", "utf-8") file.write(codecs.BOM_UTF8) file.close() It gives me the error > UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: > ordina...
Creating a logging handler to connect to Oracle? Question: So right now i need to create and implement an extension of the Python logging module that will be used to log to our database. Basically we have several python applications(that all run in the background) that currently log to a random mishmash of text files. ...
How to Change Mouse Cursor in PythonCard Question: How do I change the mouse cursor to indicate a waiting state using Python and PythonCard? I didn't see anything in the documentation. Answer: PythonCard builds on top of wx, so if you import wx you should be able to build a suitable cursor (e.g. with `wx.CursorFromI...
How to check for NaN in python? Question: `float('nan')` results in a thingy simply called nan. But how do I check for it? Should be very easy, but i cannot find it. Answer: [math.isnan()](http://docs.python.org/library/math.html#math.isnan) > Checks if the float x is a NaN (not a number). NaNs are part of the IEEE ...
Using Python's list index() method on a list of tuples or objects? Question: Python's list type has an index() method that takes one parameter and returns the index of the first item in the list matching the parameter. For instance: >>> some_list = ["apple", "pear", "banana", "grape"] >>> some_list.i...
Why won't python allow me to delete files? Question: I've created a python script that gets a list of files from a text file and deletes them if they're empty. It correctly detects empty files but it doesn't want to delete them. It gives me: (32, 'The process cannot access the file because it is being us...
Prevent a timer from updating a text box if the key cursor is in the box Question: Is it possible to check if a [`TextCtrl`](http://www.wxpython.org/docs/api/wx.TextCtrl-class.html) is under keyboard focus (blinking cursor in text box) without defining a handler for [`EVT_SET_FOCUS`](http://www.wxpython.org/docs/api/wx...
Python - simple reading lines from a pipe Question: I'm trying to read lines from a pipe and process them, but I'm doing something silly and I can't figure out what. The producer is going to keep producing lines indefinitely, like this: producer.py import time while True: print 'Data' ...
cx_Oracle And User Defined Types Question: Does anyone know an easier way to work with user defined types in Oracle using cx_Oracle? For example, if I have these two types: CREATE type my_type as object( component varchar2(30) ,key varchar2(100) ,value varchar2(4000)) / CREATE...
Redirecting FORTRAN (called via F2PY) output in Python Question: I'm trying to figure out how to redirect output from some FORTRAN code for which I've generated a Python interface by using F2PY. I've tried: from fortran_code import fortran_function stdout_holder = sys.stdout stderr_holder = sys.s...
Obfuscate strings in Python Question: I have a password string that must be passed to a method. Everything works fine but I don't feel comfortable storing the password in clear text. Is there a way to obfuscate the string or to truly encrypt it? I'm aware that obfuscation can be reverse engineered, but I think I should...
Python 3 doesn't read unicode file on a new server Question: My webpages are served by a script that dynamically imports a bunch of files with try: with open (filename, 'r') as f: exec(f.read()) except IOError: pass (actually, can you suggest a better method of importing a f...
Django : Timestamp string custom field Question: I'm trying to create a custom timestamp field. class TimestampKey(models.CharField): __metaclass__ = models.SubfieldBase def __init__(self, *args, **kwargs): import time kwargs['unique'] = True kwargs['m...
an error in taking an input in python Question: 111111111111111111111111111111111111111111111111111111111111 when i take this as input , it appends an L at the end like this 111111111111111111111111111111111111111111111111111111111111L thus affecting my calculations on it .. how can i remove it? impor...
Counting repeated characters in a string in Python Question: I want to count the number of times each character is repeated in a string. Is there any particular way to do it apart from comparing each character of the string from A-Z and incrementing a counter? **Update** (in reference to [Anthony's answer](http://stac...
Pylons FormEncode with an array of form elements Question: I have a Pylons app and am using FormEncode and HtmlFill to handle my forms. I have an array of text fields in my template (Mako) <tr> <td>Yardage</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>${h.text('y...
Segmentation fault in custom QAbstractItemModel Question: I've written my own QAbstractItemModel to show a tree in TreeView. It shows the top level items, but when you expand a directory, the app closes, the the following message is written to the console: "Segmentation fault" What am I doing wrong that is causing this...
Python - Print on stdout on a "terminal" Question: Before starting, I ask you all to apologize for the question. Maybe it is stupid, but I cannot find a solution. I am working on a remote machine, and have no idea what type. My python code, that seems to work, is the one below. The problem is that I am trying to print...
Command Line Arguments In Python Question: I am originally a C programmer. I have seen numerous tricks and "hacks" to read many different arguments. What are some of the ways Python programmers can do this? ### Related * [What’s the best way to grab/parse command line arguments passed to a Python script?](http://s...
Bash or Python to go backwards? Question: I have a text file which a lot of random occurrences of the string @STRING_A, and I would be interested in writing a short script which removes only some of them. Particularly one that scans the file and once it finds a line which starts with this string like @ST...
Python Authentication with urllib2 Question: So I'm trying to download a file from a site called vsearch.cisco.com with python [python] #Connects to the Cisco Server and Downloads files at the URL specified import urllib2 #Define Useful Variables url = 'http://vsearch.cisco.co...
How many numbers below N are coprimes to N? Question: ## In short: Given that **a** is coprime to **b** if **GCD(a,b) = 1** (where GCD stands for [great common divisor](http://en.wikipedia.org/wiki/Greatest%5Fcommon%5Fdivisor)), how many positive integers below N are coprime to N? Is there a clever way? * * * ## No...
How to replace a column using Python's built-in .csv writer module? Question: I need to do a find and replace (specific to one column of URLs) in a huge Excel .csv file. Since I'm in the beginning stages of trying to teach myself a scripting language, I figured I'd try to implement the solution in python. I'm having t...
Looping Fget with fsockopen in PHP 5.x Question: I have a Python Server finally working and responding to multiple command's with the output's, however I'm now having problem's with PHP receiving the full output. I have tried commands such as fgets, fread, the only command that seems to work is "fgets". However this o...
How do I set up a basic website with registration in Python on Dreamhost? Question: I need to write a basic website on Dreamhost. It needs to be done in Python. I discovered Dreamhost permits me to write .py files, and read them. ### Example: #!/usr/bin/python print "Content-type: text/html\n\n" ...
Formatting cells in Excel with Python Question: How do I format cells in Excel with python? In particular I need to change the font of several subsequent rows to be regular instead of bold. Thnak you, Alex Answer: Using [xlwt](http://pypi.python.org/pypi/xlwt): from xlwt import * font0 = Fo...
Flash Characters on Screen in Linux Question: I have a XFCE 4.6 on kernel 2.6. Is there a quick and easy way to flash a message on the screen for a few seconds? My Thinkpad T60 has 3 volume buttons (up, down, mute). When I pressed the buttons, I would like to flash the volume on the screen for a second on screen. Can ...
Reading binary file in Python and looping over each byte Question: In Python, how do I read in a binary file and loop over each byte of that file? Answer: f = open("myfile", "rb") try: byte = f.read(1) while byte != "": # Do stuff with byte. byte = f.read(1) finall...
In Python, how do I easily generate an image file from some source data? Question: I have some some data that I would like to visualize. Each byte of the source data roughly corresponds to a pixel value of the image. What is the easiest way to generate an image file (bitmap?) using Python? Answer: You can create ima...
wx.Panel scales to fit entire parent Frame despite giving it a size Question: Hi I am newbie to wxpython I am trying to have a Frame and within that a small panel area which I am coloring blue. However no matter what I do the wx.Panel using the size attribute , the single panel snaps to the size of its parent frame. If...
Django unit testing with date/time-based objects Question: Suppose I have the following `Event` model: from django.db import models import datetime class Event(models.Model): date_start = models.DateField() date_end = models.DateField() def is_over(self): ...
MS Access library for python Question: Is there a library for using MS Access database in python? The win32 module is not as easy as the MySQL library. Is there a simpler way to use MS Access with Python? Answer: Depending on what you want to do, [pyodbc](https://github.com/mkleehammer/pyodbc) might be what you are l...
wxPython SplitterWindow does not expand within a Panel Question: I'm trying a simple layout and the panel divided by a SplitterWindow doesn't expand to fill the whole area, what I want is this: [button] <= (fixed size) --------- TEXT AREA }...
Importing database data into Joomla Question: How to import data from a database to Joomla CMS? I have a database with lots of data I want to use in my new website. An ideal solution for me would be a Python/Perl/PHP API that would know how to do Joomla' basic routines: 1. adding/removing a section/category/materia...
formencode invalid return type Question: if an exception occurs in form encode then what will be the return type?? suppose if(request.POST): formvalidate = ValidationRule() try: new = formvalidate.to_python(request.POST) data = Users1( n_date = new...
KenKen puzzle addends: REDUX A (corrected) non-recursive algorithm Question: This question relates to those parts of the KenKen Latin Square puzzles which ask you to find all possible combinations of ncells numbers with values x such that 1 <= x <= maxval and x(1) + ... + x(ncells) = targetsum. Having tested several of...
Adding Cookie to SOAPpy Request Question: I'm trying to send a SOAP request using SOAPpy as the client. I've found some documentation stating how to add a cookie by extending SOAPpy.HTTPTransport, but I can't seem to get it to work. I tried to use the example [here](http://code.activestate.com/recipes/444758/), but th...
In Python, Using pyodbc, How Do You Perform Transactions? Question: I have a username which I must change in numerous (up to ~25) tables. (Yeah, I know.) An atomic transaction seems to be the way to go for this sort of thing. However, I do not know how to do this with pyodbc. I've seen various tutorials on atomic trans...
Translating Perl to Python Question: I found this Perl script while [migrating my SQLite database to mysql](http://stackoverflow.com/questions/18671/quick-easy-way-to-migrate- sqlite3-to-mysql/25860) I was wondering (since I don't know Perl) how could one rewrite this in Python? Bonus points for the shortest (code) a...
Get rid of toplevel tk panewindow while usong tkMessageBox Question: [link text](http://stackoverflow.com/questions/1052420/tkkinter-message-box) When I do : tkMessageBox.askquestion(title="Symbol Display",message="Is the symbol visible on the console") along with Symbol Display window tk window i...
Using SimpleXMLTreeBuilder in elementtree Question: I have been developing an application with django and elementtree and while deploying it to the production server i have found out it is running python 2.4. I have been able to bundle elementtree but now i am getting the error: "No module named expat; u...
Implementing a custom Python authentication handler Question: The answer to a [previous question](http://stackoverflow.com/questions/1080179/handling-authentication- and-proxy-servers-with-httplib2) showed that Nexus implement a [custom authentication helper](http://svn.sonatype.org/nexus/tags/nexus-1.3.4/nexus- client...
How would you adblock using Python? Question: I'm slowly building a [web browser](http://github.com/regomodo/qtBrowser/tree/master) in PyQt4 and like the speed i'm getting out of it. However, I want to combine easylist.txt with it. I believe adblock uses this to block http requests by the browser. How would you go abo...
Running JSON through Python's eval()? Question: Best practices aside, is there a compelling reason **not** to do this? I'm writing a post-commit hook for use with a Google Code project, which provides commit data via a JSON object. GC provides an HMAC authentication token along with the request (outside the JSON data)...
How do I use TLS with asyncore? Question: An asyncore-based XMPP client opens a normal TCP connection to an XMPP server. The server indicates it requires an encrypted connection. The client is now expected to start a TLS handshake so that subsequent requests can be encrypted. [tlslite](http://trevp.net/tlslite/readme....
Python remove all lines which have common value in fields Question: I have lines of data comprising of 4 fields aaaa bbb1 cccc dddd aaaa bbb2 cccc dddd aaaa bbb3 cccc eeee aaaa bbb4 cccc ffff aaaa bbb5 cccc gggg aaaa bbb6 cccc dddd Please bear with me. The first and t...
How can I parse marked up text for further processing? Question: **See updated input and output data at Edit-1.** What I am trying to accomplish is turning + 1 + 1.1 + 1.1.1 - 1.1.1.1 - 1.1.1.2 + 1.2 - 1.2.1 - 1.2.2 - 1.3 + 2 - 3 into a python...
Finding partial strings in a list of strings - python Question: I am trying to check if a user is a member of an Active Directory group, and I have this: ldap.set_option(ldap.OPT_REFERRALS, 0) try: con = ldap.initialize(LDAP_URL) con.simple_bind_s(userid+"@"+ad_settings.AD_DNS_NAME, passw...
Can python mechanize handle HTTP auth? Question: Mechanize (Python) is failing with 401 for me to open http digest URLs. I googled and tried debugging but no success. My code looks like this. import mechanize project = "test" baseurl = "http://trac.somewhere.net" loginurl = "%s/%s/login...
IRC Python Bot: Best Way Question: I want to build a bot that basically does the following: 1. Listens to the room and interacts with users and encourages them to PM the bot. 2. Once a user has PMed the bot engage with the client using various AI techniques. Should I just use the IRC library or Sockets in python...
Tkinter: AttributeError: NoneType object has no attribute get Question: I have seen a couple of other posts on similar error message but couldn't find a solution which would fix it in my case. I dabbled a bit with TkInter and created a very simple UI. The code follows- from string import * from Tkin...
Find functions explicitly defined in a module (python) Question: Ok I know you can use the dir() method to list everything in a module, but is there any way to see only the functions that are defined in that module? For example, assume my module looks like this: from datetime import date, datetime ...
Python Lambda Problems Question: What's going on here? I'm trying to create a list of functions: def f(a,b): return a*b funcs = [] for i in range(0,10): funcs.append(lambda x:f(i,x)) This isn't doing what I expect. I would expect the list to act like this: ...
List of installed fonts OS X / C Question: I'm trying to programatically get a list of installed fonts in C or Python. I need to be able to do this on OS X, does anyone know how? Answer: Python with PyObjC installed (which is the case for Mac OS X 10.5+, so this code will work without having to install anything): ...
Is it possible to pass a variable out of a pdb session into the original interactive session? Question: I am using pdb to examine a script having called `run -d` in an ipython session. It would be useful to be able to plot some of the variables but I need them in the main ipython environment in order to do that. So wh...
PyQt: event is not triggered, what's wrong with my code? Question: I'm a Python newbie and I'm trying to write a trivial app with an event handler that gets activated when an item in a custom QTreeWidget is clicked. For some reason it doesn't work. Since I'm only at the beginning of learning it, I can't figure out what...
How can I find path to given file? Question: I have a file, for example "something.exe" and I want to find path to this file How can I do this in python? Answer: Perhaps `os.path.abspath()` would do it: import os print os.path.abspath("something.exe") If your `something.exe` is not in the c...
Is it possible to go into ipython from code? Question: For my debugging needs, `pdb` is pretty good. However, it would be _much_ cooler (and helpful) if I could go into `ipython`. Is this thing possible? Answer: There is an `ipdb` project which embeds iPython into the standard pdb, so you can just do: ...
How can I make setuptools ignore subversion inventory? Question: When packaging a Python package with a setup.py that uses the setuptools: from setuptools import setup ... the source distribution created by: python setup.py sdist not only includes, as usual, the files speci...
easy, programmable data plotting Question: I spend most of my time plotting data, but unfortunately I haven't found a decent solution for my plotting needs. At the moment, the most powerful and pleasant library I found that performs plotting is matplotlib. The results are stunning, but I mostly spend my time fighting w...
MySQL db problem in Python Question: For me mysql db has been successfully instaled in my system.I verified through the following code that it is successfully installed without any errors. C:\Python26>python Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32 ...
python + Spreadsheet Question: Can anybody please tell me is there any possible way to connect to spreadsheet from python? I want to store some data from a form and submit it to google spreadsheet. Please help on this issue. What steps do I have to follow? Thanks in advance... Answer: The easiest way to connect to G...
Create NTFS junction point in Python Question: Is there a way to create an NTFS junction point in Python? I know I can call the `junction` utility, but it would be better not to rely on external tools. Answer: you can use python win32 API modules e.g. import win32file win32file.CreateSymbolicL...
Hacking JavaScript Array Into JSON With Python Question: I am fetching a .js file from a remote site that contains data I want to process as JSON using the simplejson library on my Google App Engine site. The .js file looks like this: var txns = [ { apples: '100', oranges: '20', type: 'SELL'}, ...
Python Printing StdOut As It Received Question: I'm trying to run wrap a simple (windows) command line tool up in a PyQt GUI app that I am writing. The problem I have is that the command line tool throws it's progress out to stdout (it's a server reset command so you get "Attempting to stop" and "Restarting" type outpu...
Is it possible to fetch a https page via an authenticating proxy with urllib2 in Python 2.5? Question: I'm trying to add authenticating proxy support to an existing script, as it is the script connects to a https url (with urllib2.Request and urllib2.urlopen), scrapes the page and performs some actions based on what it...
Listing builtin functions and methods (Python) Question: I have came up with this: [a for a in dir(__builtins__) if str(type(getattr(__builtins__,a))) == "<type 'builtin_function_or_method'>"] I know its ugly. Can you show me a better/more pythonic way of doing this? Answer: There is the [`inspec...
Composable Regexp in Python Question: Often, I would like to build up complex regexps from simpler ones. The only way I'm currently aware of of doing this is through string operations, e.g.: Year = r'[12]\d{3}' Month = r'Jan|Feb|Mar' Day = r'\d{2}' HourMins = r'\d{2}:\d{2}' Date = r'...
How to use a custom site-package using pth-files for Python 2.6? Question: I'm trying to setup a custom site-package directory (Python 2.6 on Windows Vista). For example the directory should be '~\lib\python2.6' ( C:\Users\wierob\lib\python2.6). Hence calling 'setup.py install' should copy packages to C:\Users\wierob\l...
Need assistance with wxPython (newbie) Question: I need to create what I _think_ should be a simple GUI. I have very little experience with building GUI's. I'm a visual learner and 'wxPython In Action' isn't helping me out. I don't learn well by books written by Ph.D.'s. I'm using Python 2.6. Many of the examples on th...
how do I read everything currently in a subprocess.stdout pipe and then return? Question: I'm using python's subprocess module to interact with a program via the stdin and stdout pipes. If I call the subprocesses readline() on stdout, it hangs because it is waiting for a newline. How can I do a read of all the charact...
Why can't I import this Zope component in a Python 2.4 virtualenv? Question: I'm trying to install Plone 3.3rc4 with plone.app.blob and repoze but nothing I've tried has worked so far. For one attempt I've pip-installed repoze.zope2, Plone, and plone.app.blob into a virtualenv. I have [this version of DocumentTemplate]...
python docstrings Question: ok so I decided to learn python (perl, c, c++, java, objective-c, ruby and a bit of erlang and scala under my belt). and I keep on getting the following error when I try executing this: Tue Jul 21{stevenhirsch@steven-hirschs-macbook-pro-2}/projects/python:-->./apache_logs.py ...
Image resizing with django? Question: I'm new to Django (and Python) and I have been trying to work out a few things myself, before jumping into using other people's apps. I'm having trouble understanding where things 'fit' in the Django (or Python's) way of doing things. What I'm trying to work out is how to resize an...
Randomness in Jython Question: When using (pseudo) random numbers in Jython, would it be more efficient to use the Python random module or Java's random class? Answer: Python's version is much faster in a simple test on my Mac: jython -m timeit -s "import random" "random.random()" 1000000 loops, ...
Iterative find/replace from a list of tuples in Python Question: I have a list of tuples, each containing a find/replace value that I would like to apply to a string. What would be the most efficient way to do so? I will be applying this iteratively, so performance is my biggest concern. More concretely, what would th...
How to exit from Python without traceback? Question: I would like to know how to I exit from Python without having an traceback dump on the output. I still want want to be able to return an error code but I do not want to display the traceback log. I want to be able to exit using `exit(number)` without trace but in c...
Good or bad practice in Python: import in the middle of a file Question: Suppose I have a relatively long module, but need an external module or method only once. Is it considered OK to import that method or module in the middle of the module? Or should `import`s only be in the first part of the module. Example: ...
Hello World from cython wiki not working Question: I'm trying to follow this tutorial from Cython: <http://docs.cython.org/docs/tutorial.html#the-basics-of-cython> and I'm having a problem. The files are very simple. I have a helloworld.pyx: print "Hello World" and a setup.py: from ...
python stdout flush and tee Question: The following code ends with broken pipe when piped into tee, but behave correctly when not piped : #!/usr/bin/python import sys def testfun(): while 1: try : s = sys.stdin.readline() except(KeyboardInterrupt) :...
combine javascript files at deployment in python Question: I'm trying to reduce the number of scripts included in our website and we use buildout to handle deployments. Has anybody successfully implemented a method of combining and compressing scripts with buildout? Answer: Here's a Python script I made that I use wi...
slow sqlite insert using the jdbc drivers in java Question: I just inserted 1million records into a simple sqlite table with five columns. It took a whooping 18 hours in java using the jdbc drivers! I did the same thing in python2.5 and it took less than a minute. The speed for select queries seem fine. I think this is...
What is the most compatible way to install python modules on a Mac? Question: I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble. On the Mac, I'm ...
Ubuntu + virtualenv = a mess? virtualenv hates dist-packages, wants site-packages Question: Can someone please explain to me what is going on with python in ubuntu 9.04? I'm trying to spin up `virtualenv`, and the `--no-site-packages` flag seems to do nothing with ubuntu. I installed `virtualenv 1.3.3` with `easy_inst...
Django newbie deployment question - ImportError: Could not import settings 'settings' Question: The app runs fine using django internal server however when I use apache + mod_python I get the below error * * * File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 75, in __init__ ...
Error drawing text on NSImage in PyObjC Question: I'm trying to overlay an image with some text using PyObjC, while striving to answer my question, ["Annotate images using tools built into OS X"](http://stackoverflow.com/questions/1229171/annotate-images-using-tools- built-into-os-x). By referencing [CocoaMagic](http:/...
MySQL LOAD DATA LOCAL INFILE example in python? Question: I am looking for a syntax definition, example, sample code, wiki, etc. for executing a LOAD DATA LOCAL INFILE command from python. I believe I can use mysqlimport as well if that is available, so any feedback (and code snippet) on which is the better route, is ...
How can I use a VB6 COM 'reference' in IronPython? Question: I'm currently developing what is more or less a script that needs to get some data from a VB 6 COM dll. This dll is currently used in a MS Word VBA project, and it exports classes, etc to the VBA code. It is added in the Tools -> References menu in the VBA ed...
How do you USE Fortran 90 module data Question: Let's say you have a Fortran 90 module containing _lots_ of variables, functions and subroutines. In your `USE` statement, which convention do you follow: 1. explicitly declare which variables/functions/subroutines you're using with the `, only :` syntax, such as `USE ...
Generating a graph with multiple (sets of multiple sets of multiple) X-axis data sets Question: I am looking for a way to generate a graph with multiple sets of data on the X-axis, each of which is divided into multiple sets of multiple sets. I basically want to take [this graph](http://gdgraph.com/samples/sample1A.htm...
can't edit line in python's command line in Linux Question: I'm running the Python CLI under Linux: bla:visualization> python Python 2.1.1 (#18, Nov 1 2001, 11:15:13) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Type "copyright", "credits" or "license" for more informati...
Is the default configuration of re incorrect on macbooks? Or have I simply misunderstood something? Question: Python came pre-installed on my macbook and I have been slowly getting acquainted with the langauge. However, it seems that my configuration of the re library is incorrect, or I simply misunderstand something a...
Simple python/Regex problem: Removing all new lines from a file Question: I'm becoming acquainted with python and am creating problems in order to help myself learn the ins and outs of the language. My next problem comes as follows: I have copied and pasted a huge slew of text from the internet, but the copy and paste...
How to include and use .eggs/pkg_resources within a project directory targeting python 2.5.1 Question: I have python .egg files that are stored in a relative location to some .py code. The problem is, I am targeting python 2.5.1 computers which require my project be self contained in a folder (hundreds of thousands of ...
get_allowed_auths() in paramiko for authentication types Question: I am trying to get supported authentication types/methods from a running SSH server in Python. I found this method get_allowed_auths() in the ServerInterface class in Paramiko but I can't understand if it is usable in a simple client-like snippet of co...
Multipart form post to google app engine not working Question: I am trying to post a multi-part form using httplib, url is hosted on google app engine, on post it says Method not allowed, though the post using urllib2 works. Full working example is attached. My question is what is the difference between two, why one w...
Reimport a module in python while interactive Question: I know it can be done, but I never remember how. How can you reimport a module in python? The scenario is as follows: I import a module interactively and tinker with it, but then I face an error. I fix the error in the .py file and then I want to reimport the fix...
Can you get more information about the online file? Question: I have a online file: <http://dl_dir.qq.com/qqfile/tm/TM2009Beta_chs.exe> ,please donot download it, i want to determine the software version whether is changed, so i want more information about it. for example, using python,i can get this: im...