WHAT IS THIS?

2007-02-16 Thread Captain
Just bought a new PC with Windows XP Media Edition.  I have two entries in 
the "Add or Remove Programs" section of Control Panel, but there is no 
corresponding item in the Start Menu.  One entry says: Python 2.2.3 and the 
other says: Python 2.2 pywin32 extensions (build203)..  The size for each is 
29.28mb.  I gather Python is a programming language, but I am wondering why 
it was installed on my PC, and is it safe to remove it?  I have no intention 
of learning the program.  Thanks in advance 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WHAT IS THIS?

2007-02-17 Thread Captain
Thanks for the responses. I'll just leave it.  Sorry about uppercase subject 
line.
"Captain" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Just bought a new PC with Windows XP Media Edition.  I have two entries in 
> the "Add or Remove Programs" section of Control Panel, but there is no 
> corresponding item in the Start Menu.  One entry says: Python 2.2.3 and 
> the other says: Python 2.2 pywin32 extensions (build203)..  The size for 
> each is 29.28mb.  I gather Python is a programming language, but I am 
> wondering why it was installed on my PC, and is it safe to remove it?  I 
> have no intention of learning the program.  Thanks in advance
> 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help on project, anyone?

2005-01-25 Thread Captain Dondo
On Sun, 23 Jan 2005 21:11:32 +0100, Georg Brandl wrote:

> Hello,
> 
> to train my Python skills I am looking for some project I can contribute
> to. I learned Python about one year ago, and had already some
> programming background behind (I contributed to SharpDevelop for
> instance), so I'm not the complete newbie.
> 
> About myself: I'm a 20 year old German with strong interests in
> programming and, of course, especially in Python (I love it...).
> 
> Does anyone run, or participate in, a project looking for fellow
> programmers? I don't have a special area of interest, well, perhaps web
> programming...
> 
> Thanks,
> Georg

Well, if you want to help, I've got a project that has been a python
learning experience for me, and it has *lots* of potential ( read: very
poor code and implementation ;-) ).

Basically, it has to do with managing and playing movies on a computer,
automatically moving them from recent arrivals to archives, keeping track
of how many times each has been played, etc.  I'd like to implement a
simple text-based record for each movie to set up the brightness, volume,
etc.

I also need to write a back end that will generate web pages for the web
interface; something along the lines of album
 but the author is taking album in
a direction that won't work for me anymore.

Email me if interested.

Remvoe the obvious from my email, and include this
kpwq1jkcsEzdx39gnkVvgycd15ayqq anywhere in your email to get through my
spam filters.

--Yan
-- 
http://mail.python.org/mailman/listinfo/python-list


Dumb*ss newbie Q

2005-03-27 Thread Captain Dondo
OK, I know this is covered somewhere in Python 101, but for the life of me
I cannot figure this out.  I really need a basic intro to Python book

I am trying to do something very simple - create an HTML tag using objects:

class Movie:

def __init__ (self, t="", a="", d=""):
#
# Create an instance of Movie
#
self.title = t
self.audience = a
self.driver = d

def set_title (self, new_title):
self.title = new_title

def set_audience (self, audience):
#
# Only 3 valid values: kids, parents, guests
#
self.audience = audience

def set_driver (self, new_driver):
self.driver = new_driver

def url (self):
self.url = "avi://" + self.audience + "/" + self.title + "/" + 
self.driver

def thumb (self):
self.thumb = self.audience + "/tn/" + self.title + ".jpg"

def html (self):
print " " + self.title + ""

#
# Code to test this class
#
if __name__ == '__main__':
print " Test 1 "
m=Movie("Fate_is_the_Hunter")
m.set_audience ("kids")
m.set_title ("Fate_is_the_Hunter")
m.set_driver 
("X=hermes.seiner.lan:xv,athena.seiner.lan:xmga,default:x11;console=vesa")
m.html ()
print "*** Finish ***"

The problem is that m.html in the test section fails with 

TypeError: cannot concatenate 'str' and 'instancemethod' objects

I got it working once.  The output should be something like this:


Fate_is_the_Hunter

but then I made some minor edits and I can't get it to work again

Where do I find documentation on Python classes?  Or how do I convert one
to the other?  Or, how do I get the above to work?  This is the first time
I've really tried to work with a class I've defined myself and I obviously
don't know what I am doing

On a minor note, if you look at the audience method, I want to limit it to
3 values.  How do I do that?

TIA

--Yan

-- 

use munged address above to email me
SpamTrap [EMAIL PROTECTED] 

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dumb*ss newbie Q

2005-03-27 Thread Captain Dondo
On Mon, 28 Mar 2005 01:15:34 +, Jp Calderone wrote:
> 
>  Notice that you have a method named "url" as well as an attribute
>  named "url".  You have the same problem for "thumb".  These methods
>  and attributes are in collision with each other.  When you try to
>  look up the attribute, you might get the method.  When you try to
>  look up the method, you might get the attribute.  It is
>  deterministic, but depends on the order in which you do things, and
>  highly confusing no matter what.  Avoid naming attributes and
>  methods the same thing.

DUH!!!

works like a charm

Thanks!

-- 

use munged address above to email me
SpamTrap [EMAIL PROTECTED] 

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dumb*ss newbie Q

2005-03-29 Thread Captain Dondo
On Mon, 28 Mar 2005 08:42:22 -0600, Larry Bates wrote:

> Others have answered your specific question, I thought I
> would add some suggestions (not tested):
> 
> 1) You don't need a separate set_title method.  You can
> change the title attribute at any time by just saying
> m.title="new title".  No method is required unless you
> need to do some pre/post processing.
> 
> m.title="anything you want"
> 
> 2) To get class to prepare its output, just insert a
> __str__ method like following:
> 
> def __str__(self):
> return 'driver="X=hermes.seiner.lan:xv,athena.seiner.lan:xmga," \
>  "default:x11;console=vesa")
> print m
> 
> 
> If you plan on doing a lot of this you may want to take a look
> at the htmlgen module at:
> 
> http://starship.python.net/crew/friedrich/HTMLgen/html/main.html
> 
> (I actually stole the idea of using the the __str__ method to
> generate the output from this module).
> 
> Hope information helps.

Thanks, it does.  I am trying to write a much simplified album -
 . The author has taken it in a
direction that is no longer useful to me and I am desparately incompetent
in perl  Python and I like each other, except that I don't have much
experience writing it from scratch

For now I am using this tutorial as a go-by:
, but I will check out
the link you provided.

--Yan

-- 

use munged address above to email me
SpamTrap [EMAIL PROTECTED] 

-- 
http://mail.python.org/mailman/listinfo/python-list


New to using re. Search for a number before a string.

2013-11-01 Thread Captain Dunsel
I have a text file that has lines with numbers occasionally appearing right 
before a person's name.  For example:

COLLEGE:ENROLLMENT:COMPLETED EVALUATIONS:624309FUDD, ELMER

where I want to search for the name "ELMER FUDD" and extract the number right 
in front of it "608309" when such a number appears but the length of the number 
is variable and using ?<= in a regular expression will only search for a fixed 
length.

Any ideas appreciated! 


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to using re. Search for a number before a string.

2013-11-02 Thread Captain Dunsel
On Friday, November 1, 2013 5:33:43 PM UTC-4, Captain Dunsel wrote:
> I have a text file that has lines with numbers occasionally appearing right 
> before a person's name.  For example:
> 
> 
> 
> COLLEGE:ENROLLMENT:COMPLETED EVALUATIONS:624309FUDD, ELMER
> 
> 
> 
> where I want to search for the name "ELMER FUDD" and extract the number right 
> in front of it "608309" when such a number appears but the length of the 
> number is variable and using ?<= in a regular expression will only search for 
> a fixed length.
> 
> 
> 
> Any ideas appreciated!

Thanks for your help, everyone!
-- 
https://mail.python.org/mailman/listinfo/python-list


Replace one element of a tuple

2006-06-01 Thread Captain Dondo
I have an array(?) (sorry, I'm new* to python so I'm probably mangling 
the terminology) that looks like this:

[((1028L, datetime.datetime(2006, 5, 30, 7, 0), datetime.datetime(2006, 
5, 30, 7, 30), 'Arthur', 'Prunella Sees the Light; Return of the 
Snowball', 'Prunella prepares for a sleepover with Marina; D.W. protects 
a snowball.', 'Children', 'tooth.seiner.lan', None, 0L, None, 1L, 1L, 
'Default', 9L, 'SH044107', 'EP0441070123', datetime.datetime(2006, 5, 
30, 7, 31, 24), 1164179392L, 0.0, 1, datetime.date(2002, 11, 28), 0, 0L, 
0),), ((1028L, datetime.datetime(2006, 5, 4, 10, 0), 
datetime.datetime(2006, 5, 4, 10, 30), 'Bob the Builder', 'Using Clues', 
'', 'Children', 'tooth.seiner.lan', None, 0L, None, 1L, 1L, 'Default', 
6L, 'SH326087', 'EP3260870141', datetime.datetime(2006, 5, 4, 10, 31, 
30), 1163673536L, 0.0, 1, datetime.date(2005, 3, 19), 0, 0L, 0),)]

I want to replace every instance of 'tooth.seiner.lan' with 'localhost'. 
  There may be lots and lots of these entries (they're pulled from my 
mythtv database).

I could brute-force this by rewriting the whole thing and replacing 
every 9th element but there has to be a better way

I've looked at various search-and-replace snippets but none that address 
what I am trying to do

--Yan

*I'm not really new to python, just very very rusty.  Last time I used 
it was about 3 years ago, and I was equally clueless
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replace one element of a tuple (LONG)

2006-06-01 Thread Captain Dondo
BartlebyScrivener wrote:
>>>I've looked at various search-and-replace snippets but none that address
>>>what I am trying to do
> 
> 
> I think you need to tell more about what you're trying to do. You say
> it's in a database? Is that why you can't just put the whole blob in
> your text editor and do search-and-replace?
> 
> And is that also why you can't turn it into a giant string and do
> giantstring.replace('unwanted','wanted')
> 
> rd
> 

Fair enough.  I am trying to pull records from one database (on 
tooth.seiner.lan) and create a smaller table with only selected elements 
in another database (on localhost aka hermes).

My code so far:

import MySQLdb
import sys, os, os.path, time, string, dialog

masterBackend="tooth.seiner.lan"
toGoBackend="hermes.seiner.lan"

masterDB=MySQLdb.connect(host=masterBackend,user="mythtv",passwd="mythtv",db="mythconverg")

# pull recordings from masterDB

c=masterDB.cursor()
c.execute("""SELECT title, subtitle, starttime FROM recorded""")

# build our dialog checkbox

d = dialog.Dialog(dialog="dialog")
d.add_persistent_args(["--backtitle", "Myth2Go"])

recordings=[]
for listing in c.fetchall():
 recordings.append(
(listing[0]+'|'+listing[2].isoformat(),
listing[1],0))

recordings.sort()

(retcode, itemlist) = d.checklist(text="",
 height=15, width=70, list_height=7,
 choices=recordings,
 title="Which recordings do you want to transfer?")

selectlist=[]
for listing in itemlist:
 print listing
 (rectitle, recdate) = listing.split('|',1)
 c.execute("""SELECT * FROM recorded WHERE title=%s AND
starttime=%s""",(rectitle,recdate))
 selectlist.append(c.fetchone())



The problem is the last line.  I am creating a bunch of tuples that are, 
for my purposes, incorrect.  I would like to create them with 
masterBackend replaced by toGoBackend.

Currently (I corrected a small bug based on another post) after a user 
selects what recordings s/he wants, selectlist contains:

[

(1028L, datetime.datetime(2006, 5, 26, 7, 0), datetime.datetime(2006, 5, 
26, 7, 30), 'Arthur', "What's Cooking?; Buster's Special Delivery", '', 
'Children', 'tooth.seiner.lan', None, 0L, None, 1L, 1L, 'Default', 9L, 
'SH044107', 'EP0441070207', datetime.datetime(2006, 5, 26, 7, 31, 1), 
1162899392L, 0.0, 0, datetime.date(2006, 5, 26), 0, 0L, 0),

(1028L, datetime.datetime(2006, 5, 27, 9, 0), datetime.datetime(2006, 5, 
27, 9, 30), 'Arthur', 'Unfinished; D.W., Bossy Boots', '', 'Children', 
'tooth.seiner.lan', None, 0L, None, 1L, 1L, 'Default', 9L, 'SH044107', 
'EP0441070204', datetime.datetime(2006, 5, 27, 9, 31, 26), 1164783552L, 
0.0, 0, datetime.date(2006, 5, 23), 0, 0L, 0),

(1028L, datetime.datetime(2006, 5, 30, 7, 0), datetime.datetime(2006, 5, 
30, 7, 30), 'Arthur', 'Prunella Sees the Light; Return of the Snowball', 
'Prunella prepares for a sleepover with Marina; D.W. protects a 
snowball.', 'Children', 'tooth.seiner.lan', None, 0L, None, 1L, 1L, 
'Default', 9L, 'SH044107', 'EP0441070123', datetime.datetime(2006, 5, 
30, 7, 31, 24), 1164179392L, 0.0, 1, datetime.date(2002, 11, 28), 0, 0L, 0)

]

which is the correct format to insert into the new database.

What I'd like to do is build the correct selectlist in the first place, 
rather than build the wrong one and then rebuild a correct one.

I can't find a replace method that would work on a tuple (not surprising 
since they're immutable) but I also can't find a replace function that 
would replace an element of a tuple and return a new tuple.

--Yan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replace one element of a tuple (LONG)

2006-06-01 Thread Captain Dondo
Brian wrote:
> Captain Dondo wrote:
> 
>>What I'd like to do is build the correct selectlist in the first place,
>>rather than build the wrong one and then rebuild a correct one.
> 
> 
> This is sounding more like a SQL/DB problem and less like a Python one.
>  If you have a field that is being pulled from the database that you
> would like to do a substitution on, I'm fairly sure MySQL includes a
> CASE statement in their flavor of SQL.  Instead of performing a  SELECT
> * in your script you could select the individual fields you want, and
> instead of just pulling the problematic column as is, you could pull it
> as something like "select case when sourcehost = x then y else
> sourcehost end case, ...".  Naturally if an entire column needs to be
> replaced with a static value, you won't even need to use CASE.
> 

AFAICT, that one column is always the same, the name of the host that 
the database resides on.  As myth can use multiple backends , it sort of 
makes sense, but it seems redunandant to me.  Even with mutliple 
backends, I would hope you have a single database

I thought about just picking all the other fields via the SQL query, but 
this seemed simpler to me

Anyway, here's the code I came up with:

for listing in itemlist:
 (rectitle, recdate) = listing.split('|',1)
 c.execute("""SELECT * FROM recorded WHERE title=%s AND 
starttime=%s""",(rectitle,recdate))
 for listitem in c.fetchall():
 if 'tooth.seiner.lan' in  listitem:
 selectlist.append(listitem[:7] + 
('hermes.seiner.lan',) + listitem[9:])
 else:
 selectlist.append(listitem)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replace one element of a tuple (LONG)

2006-06-01 Thread Captain Dondo
BartlebyScrivener wrote:
>>>that one column is always the same, the name of the host that
>>>the database resides on.
> 
> 
> Then why are you pulling all of the other stuff out of the db? Why
> don't you just
> 
> UPDATE tablename
> SET hostname(or colname) = 'localhost'
> WHERE search condition = the rows you want to change
> 

Well, there is an interactive dialog where the user picks which records 
s/he wants to put into the other database.  So in the target database, 
that table may not even exist until the user selects which records go in 
there.

But it does sound like I need to do some work on the database query  :-)

--Yan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: updating db with csv

2007-06-11 Thread Captain Paralytic
On 11 Jun, 07:37, Tim Roberts <[EMAIL PROTECTED]> wrote:
| Not in standard SQL.  MySQL supports a REPLACE extension that does
an
| UPDATE if the key already exists, and an INSERT if it does not.
 There is
| also an extension clause to the INSERT statement called "ON
DUPLICATE KEY
| UPDATE xxx" that might do what you want.
| --
| Tim Roberts, [EMAIL PROTECTED]
| Providenza & Boekelheide, Inc.

No Tim, that is not correct. the REPLACE extension does not do an
update, it does a replace. It delets the old record and inserts a new
one. The INSERT...ON DUPLICATE KEY UPDATE... does an update. So a
REPLACE will remove all existing field values not referenced in the
statement, whilst an INSERT...ON DUPLICATE KEY UPDATE... will preserve
them. Also REPLACE will make a TIMESTAMP column which has a DEFAULT
CURRENT_TIMESTAMP setting work like one which has ON UPDATE
CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP setting.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: updating db with csv

2007-06-13 Thread Captain Paralytic
On 13 Jun, 06:35, Tim Roberts <[EMAIL PROTECTED]> wrote:
> Captain Paralytic <[EMAIL PROTECTED]> wrote:
> >On 11 Jun, 07:37, Tim Roberts <[EMAIL PROTECTED]> wrote:
> >| Not in standard SQL.  MySQL supports a REPLACE extension that does
> >| an UPDATE if the key already exists, and an INSERT if it does not.
> >| There is also an extension clause to the INSERT statement called
> >| "ON DUPLICATE KEY UPDATE xxx" that might do what you want.
>
> >No Tim, that is not correct. the REPLACE extension does not do an
> >update, it does a replace. It delets the old record and inserts a new
> >one. The INSERT...ON DUPLICATE KEY UPDATE... does an update. So a
> >REPLACE will remove all existing field values not referenced in the
> >statement, whilst an INSERT...ON DUPLICATE KEY UPDATE... will preserve
> >them. Also REPLACE will make a TIMESTAMP column which has a DEFAULT
> >CURRENT_TIMESTAMP setting work like one which has ON UPDATE
> >CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP setting.
>
> Thanks for the correction; that's an important difference.  I'm a Postgres
> guy; if I had noticed this was cross-posted to c.d.mysql as well as
> comp.lang.python, I probably would have kept quiet.
> --
> Tim Roberts, [EMAIL PROTECTED]
> Providenza & Boekelheide, Inc.

But then you wouldn't have learned about this important difference. I
too learn a lot when I give what I think is a correct answer and then
have someone else explain what really happens.

The wonder of usenet.

-- 
http://mail.python.org/mailman/listinfo/python-list


Where is the syntax for the dict() constructor ?!

2007-07-05 Thread Captain Poutine
I'm simply trying to read a CSV into a dictionary.

(if it matters, it's ZIP codes and time zones, i.e.,
35983,CT
39161,CT
47240,EST



Apparently the way to do this is:

import csv

dictZipZones = {}

reader = csv.reader(open("some.csv", "rb"))
for row in reader:
 # Add the row to the dictionary


But how to do this?

Apparently there is no dict.append() nor dict.add()

But what is there?  I see vague references to "the dict() constructor" 
and some examples, and news that it has been recently improved.  But 
where is the full, current documentation for the dict() constructor?

Frustrated,
Captain Poutine

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where is the syntax for the dict() constructor ?!

2007-07-05 Thread Captain Poutine
Neil Cerutti wrote:
> On 2007-07-05, Captain Poutine <[EMAIL PROTECTED]> wrote:
>> I'm simply trying to read a CSV into a dictionary.
>>
>> (if it matters, it's ZIP codes and time zones, i.e.,
>> 35983,CT
>> 39161,CT
>> 47240,EST
>>
>>
>>
>> Apparently the way to do this is:
>>
>> import csv
>>
>> dictZipZones = {}
>>
>> reader = csv.reader(open("some.csv", "rb"))
>> for row in reader:
>>  # Add the row to the dictionary
> 
> In addition to Chris's answer, the csv module can read and write
> dictionaries directly. Look up csv.DictReader and csv.DictWriter.
> 

Yes, thanks.  I was happy when I saw it at 
http://www.python.org/doc/2.4/lib/node615.html


"Reader objects (DictReader instances and objects returned by the 
reader() function) have the following public methods:

next(   )
 Return the next row of the reader's iterable object as a list, 
parsed according to the current dialect."

But that's not enough information for me to use.  Also, the doc says 
basically "csv has dialects," but doesn't even enumerate them.  Where is 
the real documentation?


Also, when I do a print of row, it comes out as:
['12345', 'ET']

But there are no quotes around the number in the file.  Why is Python 
making it a string?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where is the syntax for the dict() constructor ?!

2007-07-05 Thread Captain Poutine
Peter Otten wrote:
> Neil Cerutti wrote:
> 
>> On 2007-07-05, Captain Poutine <[EMAIL PROTECTED]> wrote:
>>> I'm simply trying to read a CSV into a dictionary.
>>>
>>> (if it matters, it's ZIP codes and time zones, i.e.,
>>> 35983,CT
>>> 39161,CT
>>> 47240,EST
>>>
>>>
>>>
>>> Apparently the way to do this is:
>>>
>>> import csv
>>>
>>> dictZipZones = {}
>>>
>>> reader = csv.reader(open("some.csv", "rb"))
>>> for row in reader:
>>>  # Add the row to the dictionary
>> In addition to Chris's answer, the csv module can read and write
>> dictionaries directly. Look up csv.DictReader and csv.DictWriter.
> 
> DictReader gives one dict per row, with field names as keys. The OP is more
> likely to want
> 
> dict(csv.reader(open("some.csv", "rb")))
> 
> which produces a dict that maps ZIP codes to time zones.
> 
> Peter
> 

Thanks Peter, that basically works, even if I don't understand it.

What does "rb" mean? (read binary?)
Why are the keys turned into strings (they are not quoted in the .csv file)?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do you know what's CGI? (web history personal story)

2011-01-15 Thread Captain Obvious

XL> ... i recall, i stopped doing Mathematica in 1998 because it's a
XL> career dead-end as a programing lang, and dived into the utterly
XL> idiotic Perl & unix & mysql world. (See: The Unix Pestilence ◇ Xah
XL> Lee's Computing Experience (Impression Of Lisp from Mathematica).)

I guess you're calling "idiotic" everything you're too lazy to understand.

XL> today were under 10 in the 1990s. They wouldn't know what was CGI, and
XL> no amount of explanation can tell them exactly it was like, because it
XL> has become HISTORY — if you didn't live it, you can't feel it.

CGI is still used in some places today, hello?
If spawning a process for each request is what you want to do, it is a way 
to go.


inetd is quite similar to CGI and, guess what, it is still used. 


--
http://mail.python.org/mailman/listinfo/python-list