Naming dictionaries recursively

2007-08-17 Thread TYR
I'd like to do something like this; iterate through a file which consists of data stored in dictionary format, one dict on each line, and read each line into a new dict using one of the values in the dict as its name... for example: stuff = open('data.txt') for eachLine in stuff: name{} nam

Re: Naming dictionaries recursively

2007-08-17 Thread TYR
> So the tougher problem seems to be parsing those lines. That is not a > valid Python dictionary unless the names `Bob`, `Humboldt`, `red`, and > `predatory` are not already defined. So you can't just ``eval`` it. In what way? {'key': val}, right? Anyway, I can always change the format they g

Re: Naming dictionaries recursively

2007-08-18 Thread TYR
That sounds like a solution. I think the core of the question is as follows; if I was to call the dict() function for each line, thus creating a dictionary, and then rename it to dict['name'], will there be a namespace collision on the next loop when dict() is called again? Obviously the first dict

Re: Python module for making Quicktime or mpeg movies from images

2007-10-12 Thread TYR
On Oct 11, 4:17 pm, Tim Golden <[EMAIL PROTECTED]> wrote: > jeremito wrote: > > On Oct 11, 10:43 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > >> jeremito wrote: > >>> My Python script makes a bunch of images that I want to use as frames > >>> in a movie. I've tried searching for a module th

SQLite3; weird error

2007-10-29 Thread TYR
Has anyone else experienced a weird SQLite3 problem? Going by the documentation at docs.python.org, the syntax is as follows: foo = sqlite3.connect(dbname) creates a connection object representing the state of dbname and assigns it to variable foo. If dbname doesn't exist, a file of that name is c

Re: SQLite3; weird error

2007-10-29 Thread TYR
On Oct 29, 11:51 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > TYR <[EMAIL PROTECTED]> wrote: > > To do anything with it, you then need to create a cursor object by > > calling foo's method cursor (bar = foo.cursor). > > Perhaps this would work better if

Re: Python web frameworks

2007-11-22 Thread TYR
Perhaps we need a pythonic FRONTEND. If you're meant to be able to run java code in a browser vm; and flash; and javascript...why not a reduced version of python? I'm thinking a sandboxed interpreter, perhaps based on EmbeddedPython, and a restricted set of classes; core logic, string and maths,

Extracting data from dump file

2007-11-23 Thread TYR
I have a large dump file that originated in a MySQL db; I need to get it into an SQLite file. Various options are suggested around the web; none of them seem to work (most failing to import the thing in the first place). So I removed the assorted taggery from each end, leaving just a big text file

Re: Python web frameworks

2007-11-23 Thread TYR
On Nov 23, 4:22 am, SamFeltus <[EMAIL PROTECTED]> wrote: > """Perhaps we need a pythonic FRONTEND. """ > > Should have happened years ago. Python Internet Environment: PIE. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python web frameworks

2007-11-29 Thread TYR
On Nov 29, 3:15 pm, Aaron Watters <[EMAIL PROTECTED]> wrote: > On Nov 22, 11:22 pm, SamFeltus <[EMAIL PROTECTED]> wrote: > > > """Perhaps we need a pythonic FRONTEND. """ > > > Should have happened years ago. > > It did. Mark Hammond embedded Python under MSIE about > the same time javascript and

time.strptime() undocumented difference python 2.5.1>2.5.2

2009-03-25 Thread TYR
A server that runs one of my programs was upgraded to Debian Lenny last night, which moved it from Python 2.4.4 to 2.5.2. This caused immediate trouble. At one point, data is parsed from a Web page, and among other things a time date group is collected. This is in a nice human readable format, but

Re: time.strptime() undocumented difference python 2.5.1>2.5.2

2009-03-25 Thread TYR
On Mar 25, 7:38 pm, MRAB wrote: > TYR wrote: > > A server that runs one of my programs was upgraded to Debian Lenny > > last night, which moved it from Python 2.4.4 to 2.5.2. This caused > > immediate trouble. At one point, data is parsed from a Web page, and > > amo

Strange thing with types

2008-05-29 Thread TYR
I'm doing some data normalisation, which involves data from a Web site being extracted with BeautifulSoup, cleaned up with a regex, then having the current year as returned by time()'s tm_year attribute inserted, before the data is concatenated with string.join() and fed to time.strptime(). Here's

Re: Strange thing with types

2008-05-29 Thread TYR
On May 29, 2:23 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > TYR wrote: > > I'm doing some data normalisation, which involves data from a Web site > > being extracted with BeautifulSoup, cleaned up with a regex, then > > having the current year

Re: Strange thing with types

2008-05-29 Thread TYR
On May 29, 2:24 pm, alex23 <[EMAIL PROTECTED]> wrote: > On May 29, 11:09 pm, TYR <[EMAIL PROTECTED]> wrote: > > > > > I'm doing some data normalisation, which involves data from a Web site > > being extracted with BeautifulSoup, cleaned up with a regex, the

Re: Making wxPython a standard module?

2008-06-17 Thread TYR
>" b = wx.Button(label="Click Me", action=myCallable) >Instead you used to have to create a button and then call >some utility function in some other object to bind that >button to a callable (IIRC this was one place where Window >IDs could be used). Now, the button actually

Strange re problem

2008-06-20 Thread TYR
OK, this ought to be simple. I'm parsing a large text file (originally a database dump) in order to process the contents back into a SQLite3 database. The data looks like this: 'AAA','PF',-17.4167,-145.5,'Anaa, French Polynesia','Pacific/ Tahiti','Anaa';'AAB','AU',-26.75,141,'Arrabury, Que

Re: Strange re problem

2008-06-20 Thread TYR
>How do you propose to parse that string into a "set of values"? Can >you rely there being data commas only in the 5th field, or do you need >a general solution? What if (as Peter remarked) there is a ';' in the >data? What if there's a "'" in the data (think O'Hare)? My plan was to be pointlessl

Re: Strange re problem

2008-06-21 Thread TYR
On Jun 20, 3:35 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > On Jun 20, 6:01 am, TYR <[EMAIL PROTECTED]> wrote: Thank you very much. This pyparsing module looks damned useful. -- http://mail.python.org/mailman/listinfo/python-list

Re: Mobile Devices

2008-06-25 Thread TYR
On Jun 25, 10:38 am, rodmc <[EMAIL PROTECTED]> wrote: > Hi, > > I have been scouting around online for information on how to use > Python and a GUI toolikit to develop mobile devices. At present I am > using wxPython for desktop apps and would like to continue using that > if possible. Anyway, I wo

Re: How is GUI programming in Python?

2008-04-16 Thread TYR
Who cares? Everyone does their GUI in a browser these days - keep up, Dad. What we need is a pythonic front end. /troll -- http://mail.python.org/mailman/listinfo/python-list

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread TYR
Use csv.DictReader to get a list of dicts (you get one for each row, with the values as the vals and the column headings as the keys) and then do a len(list)? -- http://mail.python.org/mailman/listinfo/python-list

Re: JSON from Python mysqldb

2008-08-27 Thread TYR
There's always the naive option. query = ('species', 'lifestyle', 'coolness', 'tentacles=>8') db.execute('SELECT %s, %s, %s % FROM creatures WHERE %s;' % query) record = dict(zip((query), (db.fetchall())) array = '''{ ''' for k,v in record: array.append('"(k)":"(v)"') array.append('

Re: JSON from Python mysqldb

2008-08-27 Thread TYR
On Aug 27, 2:37 pm, TYR <[EMAIL PROTECTED]> wrote: > There's always the naive option. > > query = ('species', 'lifestyle', 'coolness', 'tentacles=>8') > db.execute('SELECT %s, %s, %s % FROM creatures WH

urllib2 content-type headers

2009-06-21 Thread TYR
I have a little application that wants to send data to a Google API. This API requires an HTTP header to be set as follows: Authorization: GoogleLogin auth=[value of auth token goes here] Unfortunately, I'm getting nothing but 400 Bad Requests. I suspect this is due to an unfeature of urllib2. No