I have this line of code:
a/b
I am using these inputs:
a=[1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9]
b=ones(25,18)
this is the result:
[5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], a 1x25 matrix.
what is matlab doing? I am trying to duplicate this behavior in Python, and the mrdivide documentation in matlab was unhelpful. where d...
I want to replace whitespace with underscore in a string to create nice URLs. So that for example:
"This should be connected" becomes "This_should_be_connected"
I am using Python with Django. Can this be solved using regular expressions?
...
I have some egg accessible as a URL, say http://myhosting.com/somepkg.egg .
Now I don't have this somepkg listed on pypi. How do I tell buildout to fetch and install it for me.
I have tried a few recipes but no luck so far.
TIA
...
Suppose I have a set of column definitions:
Col1: value11 value12 value13
Col2: value21 value22
Col3: value31 value32 value33
...
Given some subset of columns -- 2 or more -- I want to find all possible values for those columns. Suppose I choose columns 1 and 2, above:
(value11 value21)
(value11 value22)
(value12 value21)
(value12 ...
Working on some code and I'm given the error when running it from the command prompt...
NameError: name 'Popen' is not defined
but I've imported both import os and import sys.
Here's part of the code
exepath = os.path.join(EXE File location is here)
exepath = '"' + os.path.normpath(exepath) + '"'
cmd = [exepath, '-el', str(el), '-n'...
I'm working on a plugin for Trac and am inserting some javascript into the rendered HTML by manipulating the Genshi stream.
I need to test if a javascript function is already in the HTML and if it is then overwrite it with a new version, if it isn't then add it to the HTML.
How do I perform a search to see if the function is already th...
I'm having issues with threads and PyGTK on Windows. According the the PyGTK FAQ (and my own experimentation), the only way to reliably update the GUI from a child thread is to use the gobject.idle_add function. However, it can't be guaranteed when this function will be called. How can I guarantee that the line following the gobject.i...
I'm editing a file in ~/Documents. However, my working directory is somewhere else, say ~/Desktop.
The file I'm editing is a Python script. I'm interested in doing a command like...
:!python
without needing to do
:!python ~/Documents/script.py
Is that possible? If so, what would be the command?
Thank you.
...
I have 3 text files
many lines of value1<tab>value2 (maybe 600)
many more lines of value2<tab>value3 (maybe 1000)
many more lines of value2<tab>value4 (maybe 2000)
Not all lines match, some will have one or more vals missing. I want to take file 1, read down it and lookup corresponding values in files 2 & 3, and write the output as -...
I'm trying to start up a child process and get its output on Linux from Python using the subprocess module:
#!/usr/bin/python2.4
import subprocess
p = subprocess.Popen(['ls', '-l', '/etc'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = p.communicate()
However, I experience some flaki...
I'm trying to get into the Clojure community. I've been working a lot with Python, and one of the features I make extensive use of is the zip() method, for iterating over pairs of values. Is there a (clever and short) way of achieving the same in Clojure?
...
Google's finance API is incomplete -- many of the figures on a page such as:
http://www.google.com/finance?fstype=ii&q=NYSE:GE
are not available via the API.
I need this data to rank companies on Canadian stock exchanges according to the formula of Greenblatt, available via google search for "greenblatt index scans".
My questio...
Problem: to find answers and exercises of lectures in Mathematics at Uni. Helsinki
Practical problems
to make a list of sites with .com which has Disallow in robots.txt
to make a list of sites at (1) which contain files with *.pdf
to make a list of sites at (2) which contain the word "analyysi" in pdf-files
Suggestions for practical...
Simple question - I am creating a two dim array (ddist = [[0]*d for _ in [0]*d]) using lists in the code below. It outputs distance using gis data. I just want a simple way to take the result of my array/list and output to a text file keeping the same N*N structure. I have used output from print statements in the past but not a good sol...
I'm trying to parse a twitter feed in django, and I'm having a strange problem converting the published time:
I've got the time from the feed into a full 9-tuple correctly:
>> print tweet_time
time.struct_time(tm_year=2009, tm_mon=6, tm_mday=17, tm_hour=14, tm_min=35, tm_sec=28, tm_wday=2, tm_yday=168, tm_isdst=0)
But when I call thi...
I want some application to look like widget inside my Python application.
That's all. I dont need any interaction between them. I'm interested in solutions in any GUI toolkit for both windows and x windows.
It would be nice to have a solution with Tkinter but it's not crucial.
...
Hola,
Is there any way for me to use a string to call a method of a class? Here's an example that will hopefully explain better (using the way I think it should be)
class helloworld():
def world(self):
print "Hello World!"
str = "world"
hello = helloworld()
hello.`str`()
Which would output hello world.
Thanks in advanc...
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?
Implementing a “[command] [action] [parameter]” style command-line interfaces?...
I am trying to write a "login_required" decorator for the views in a WSGI+Werkzeug application.
In order to do this, I need to get at the user's session, which is accessible via the Request object that is passed into the view methods.
I can't figure out how to get at that instance of Request in the decorator, though. I looked at PEP318...
Suppose I have a byte stream with the following in it:
POST /mum/ble?q=huh
Content-Length: 18
Content-Type: application/json; charset="utf-8"
Host: localhost:80
["do", "re", "mi"]
Is there a way to produce an WSGI-style 'environ' dict from it?
Hopefully, I've overlooked an easy answer, and it is as easy to achieve as the opposite o...