Suppose I have a list of filenames: [exia.gundam, dynames.gundam, kyrios.gundam, virtue.gundam], or [exia.frame, exia.head, exia.swords, exia.legs, exia.arms, exia.pilot, exia.gn_drive, lockon_stratos.data, tieria_erde.data, ribbons_almark.data, otherstuff.dada].
In one iteration, I'd like to have all the *.gundam or *.data files, where...
def myfunc(x):
y = x
y.append('How do I stop Python from modifying x here?')
return y
x = []
z = myfunc(x)
print(x)
...
Hi.
I am preparing a master class to present to a group of Technical Artists# at work. Everyone in the group has previously programmed in C/C++/MEL/MAXScript/Python. The purpose of the class is to collectively bring everyone's skill levels and technical understanding on variety of Computer Science topics to a common level.
I would li...
Is there a library which can take a python dict with word freq = { 'abc' : 25, .... }
and convert this into a html based Tag Cloud?
...
I was wondering:
In python, canon says to use buildout or virtualenv, to avoid installing into the system packages. It's second nature now, I no longer see anything ludicrously bizarre to the practice. It makes a kind of sense.
In Ruby, is there something similar? How does ruby deal with this problem? Does ruby have this problem?
...
I've asked almost this just before now, but the fix doesn't work for x = [[]], which I'm guessing is because it is a nested list, which is what I will be working with.
def myfunc(w):
y = w[:]
y[0].append('What do I need to do to get this to work here?')
y[0].append('When I search for the manual, I get pointed to python.org, but I can...
How do I make this code remember the last position of the scale, upon reopening?
import Tkinter
import cPickle
root = Tkinter.Tk()
root.sclX = Tkinter.Scale(root, from_=0, to=1500, orient='horizontal', resolution=1)
root.sclX.pack(ipadx=75)
root.resizable(False,False)
root.title('Scale')
with open('myconfig.pk', 'wb') as f:
...
I'm trying to modify items in a list using a for loop, but I get an error (see below). Sample code:
#!/usr/bin/env python
# *-* coding: utf8 *-*
data = []
data.append("some")
data.append("example")
data.append("data")
data.append("here")
for item in data:
data[item] = "everything"
Error:
Traceback (most recent call last):
Fil...
Hello,
I am new to vim so I was trying to edit an existing script for the vimrc file. The script will take the content of the current buffer and copy it into a new window and then run Python.
The scrip works but the preview window is always 50% of the current window.
This is the script:
" Preview window for python
fu! DoRunPyBuffer2(...
What would be the best way to execute shell commands on remote servers and get output without actually logging in.
Maybe with shh keys. Preferably with python.
...
The components of the URLs of the Django app I'm working on are very 'pluggable', and different combinations of them get used in various urlpatterns, so our urls.py looks something like:
rev = r'(/R\.(?P<rev>\d+))?'
repo_type= r'^(?P<repo_type>svn|hg)/'
path = r'/dir/(?P<path>.*)$'
# etc.
urlpatterns = patterns('',
(repo_type_param...
Using Windows' WMI library, how can I eject CD rom mounted in a specific CD/DVD drive?
I am asking for sources from WMI docs or examples since I am using wmi.py library on Python.
It would be great if solution satisfies Windows computer newer than Windows 2000 and having multi CD-ROMs. (i.e. I have D: F: drives and both are CD-ROM dri...
How do I download a remote file into several chunks using twisted? Lets say if the file is 100 bytes, I want to spawn 10 connection which will read 10 bytes each but in no particular order and then later on merge them all.
I was able to do this using threads in Python but I don't have any idea how to use twisted's reactor + manager + pr...
False is equivalent to 0 and True is equivalent 1 so it's possible to do something like this:
def bool_to_str(value):
"""value should be a bool"""
return ['No', 'Yes'][value]
bool_to_str(True)
Notice how value is bool but is used as an int.
Is this this kind of use Pythonic or should it be avoided?
...
Here's the python list of strings:
patterns = [
"KBKKB",
"BBBK",
"BKB",
"KBBB",
"KBB",
"BKBB",
"BBKB",
"KKBKB",
"BKBK",
"KBKB",
"KBKBK",
"BBK",
"BB",
"BKKB",
"BBB",
"KBBK",
"BKKBK",
"KB",
"KBKBK",
"KKBKKB",
"KBK",
"BBKBK",
"BBBB",
"BK",
"KKBKBK",
"KBBKB",
"BBKKB",
"KKKKBB",
"KKB"
]
I have an input string that consist of K and B only of...
i would like a python script to draw in 3D a triangle bezier patch
this is an old problem and there must be some old script available to do this somehwere!
Thanks for any help
...
I have the following piece of code overriding the save method of a model:
@transaction.commit_on_success
def save(self, *args, **kwargs):
try:
transaction.commit()
self.qa.vote_down_count += 1
self.qa.save()
super(self.__class__, self).save(*args, **kwargs)
except:
transaction.rollback(...
import urllib2, cookielib
import ClientForm
from BeautifulSoup import BeautifulSoup
first_name = "Mona"
last_name = "Sahlin"
url = 'http://www.ratsit.se/BC/Search.aspx'
cookiejar = cookielib.LWPCookieJar()
cookiejar = urllib2.HTTPCookieProcessor(cookiejar)
opener = urllib2.build_opener(cookiejar)
urllib2.install_opener(opener)
respons...
I have the following tables defined declaratively (very simplified version):
class Profile(Base):
__tablename__ = 'profile'
id = Column(Integer, primary_key = True)
name = Column(String(65), nullable = False)
def __init__(self, name):
self.name = name
class Question(Base):
__tablename_...
I am using SQLAlchemy 0.4.8 with Postgres in order to manage my datastore. Until now, it's been fairly easy to automatically deploy my database: I was using metadata.create_all(bind=engine) and everything worked just fine. But now I am trying to create a sequence that it's not being used by any table, so create_all() doesn't create it, e...