python

Non-sequential substitution in SymPy

I'm trying to use [SymPy][1] to substitute multiple terms in an expression at the same time. I tried the [subs function][2] with a dictionary as parameter, but found out that it substitutes sequentially. In : a.subs({a:b, b:c}) Out: c The problem is the first substitution resulted in a term that can be substituted by the second substi...

How to exit when viewing python help like help(os.listdir)

when the help window pops up, what are the basic commands (mac os) to page up/down, end of document and exiting the help screen? I just had to close my terminal as I couldn't figure it out! ...

Change Unix password from command line over Python/Fabric

I would like a way to update my password on a remote Ubuntu 10.4 box with fabric. I would expect my fabfile.py would look something like this: def update_password(old_pw, new_pw): # Connects over ssh with a public key authentication run("some_passwd_cmd --old %s --new %s" % (old_pw, new_pd)) Unfortunately the only command I k...

Defining a part of a column as a unique field in sqlalchemy

In sqlalchemy 0.5 i have a table defined like this one: orders = Table('orders', metadata, Column('id', Integer, primary_key=True), Column('responsable', String(255)), Column('customer', String(255)), Column('progressive', Integer), Column('date', Date), Column('exported', Boolean()), ) Is it possible t...

why cant i use ttk in python?

when i type from Tkinter import ttk it say that there is no module named ttk and also on many websites online the t in tkinter is always lowercase but when i type tkinter in python it throws an error. why is that? ...

python multiprocessing - text processing

hi, I am trying to create a multiprocessing version of text categorization code i found here (amongst other cool things). I've appended the full code below. I've tried a couple of things - tried a lambda function first, but it complained of not being serializable (!?), so attempted a stripped down version of the original code: negi...

Reconstituting Strings in Python

I would like to do something like: temp=a.split() #do some stuff with this new list b=" ".join(temp) where a is the original string, and b is after it has been modified. The problem is that when performing such methods, the newlines are removed from the new string. So how can I do this without removing newlines? ...

Template tags like Django with Mako and Pylons

Hi to all, For my site need some "widgets" that elaborate output from various data models, because this widgets are visible in any page is possible with mako to retrieve the data without pass (and elaborate) every time with render() in controllers? ...

Find previous calendar day in python

I have a set of files that I'm saving by date, year_month_day.txt format. I need to open the previous day's text file for some processing. How do I find the previous day's date in python? ...

What methods and tools do you use to design and analyze the workflow in a web application (for a tiny team)

Note: I use TRAC integrated with SVN, framework testing tools, an excellent mixture of staging servers, development servers, and other tools to speed development and keep track of tasks. I am asking about the specific process of design, and even more specifically, the design of functionality and flow in a web application. --- Original ...

Changing a files metadata in Python

Ok, I've searched around here but haven't found anything pointing to a solid answer. I'm trying to change a files artist, filename, rating, genre etc in windows, which shows up when you view folders in 'details'. At the moment I have the files I wish to edit in a list and I am iterating through them, but as I said I am not sure how to ...

Python: Any way to declare constant parameters?

I have a method: def foo(bar): # ... Is there a way to mark bar as constant? Such as "The value in bar cannot change" or "The object pointed to by bar cannot change". ...

using 'variable.xyz' format in Python

Hi, This is a silly question, but I can't figure it out so I had to ask. I'm editing some Python code and to avoid getting too complicated, I need to be able to define a new variable along the lines of : Car.store = False. Variable Car has not been defined in this situation. I know I can do dicts (Car['store'] = False) etc... but it h...

texmate and django, is there intellisense?

New to mac and textmate AND python. I don't seem to be getting any intellisensewith textmate, is there a plugin? what are the keyboard shortcuts I should know about (basic ones at this point). thanks! ...

Stateless pagination in CouchDB?

Most of the research I've seen on pagination with CouchDB suggests that what you need to do is take the first ten (or however many) items from your view, then record the last document's docid and pass it on to the next page. Unfortunately, I can see a few glaring issues with that method. It apparently makes it impossible to skip around...

can someone help me with tags in canvas?

i tried to figure out what tags were in canvas however i am having a hard time understanding it. can someone explain what tags do and how to use them in canvas when using python. ...

Python out params?

Is it possible to do something like this: def foo(bar, success) success = True # ... >>> success = False >>> foo(bar1, success) >>> success True Does Python have out params, or an easy way to simulate them? (Aside from messing with parent's stack frames.) ...

python win32com Causes Program crash

I wrote program to control iTunes by monitoring keystrokes from with pyHooks and then interfaceing with the iTunes COM interface. The program works fine, the only problem I have is when I try to compile it with py2exe. The program always crashes with this traceback: Traceback (most recent call last): File "threading.pyc", line 527, i...

question regarding postgresql sequences

Hi guys, I have a question regarding postgresql sequences. For instance, for bigserial datatype, is it true that the sequence is advanced, then the number is retrieved and even if the insertion/committing is not successful, the sequence doesn't backtracks. Which means the next time I might be doing insertion to the table, that might be...

Python Module Initialization Order?

Hi, I am a Python newbie coming from a C++ background. While I know it's not Pythonic to try to find a matching concept using my old C++ knowledge, I think this question is still a general question to ask: Under C++, there is a well known problem called global/static variable initialization order fiasco, due to C++'s inability to decid...