Re: Idempotent XML processing

2005-08-19 Thread Michael Ekstrand
On Aug 19, 2005, at 1:20 PM, Robert Kern wrote:
 Read up on XML canonicalization (abrreviated as c14n). lxml implements
 this, also xml.dom.ext.c14n in PyXML. You'll need to canonicalize on
 both ends before hashing.

 To paraphrase an Old Master, if you are running a cryptographic hash
 over a non-canonical XML string representation, then you are living in 
 a
 state of sin.

Canonicalization seems to be the needed thing. Looking at the protocol 
specification again, it mentions canonicalization; I had glossed over 
that previously because I was unware of any defined meaning it had. But 
the c14n module should provide the needed results (now that I've 
finally dug up documentation for it).

-Michael

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


Re: python classes taught

2005-08-19 Thread Simon Percivall
Yeha, sure. The Royal Institute of Technology in Stockholm, Sweden
teaches Python for some of its introductory programming and algorithm
courses.

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


Re: Confused newbie needs help with __init__() takes exactly 11 arguments (1 given)

2005-08-19 Thread [EMAIL PROTECTED]
it looks like your problem is in this line:
reviews = [Review(*[field.strip() for field in row]) for row in reader]

ouch! split that up a bit so we can understand what the heck you are
trying to do here. Also, it appears the whole thing is in these [ ] ?
why?

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


Re: global interpreter lock

2005-08-19 Thread Gregory Piñero
Would a cheap solution just be to run two python interpreters and have
the scripts communicating over COM or some other such thing? I'd
imagine that would give you true parallelism.

-GregOn 8/19/05, Donn Cave [EMAIL PROTECTED] wrote:
In article [EMAIL PROTECTED] , Bryan Olson [EMAIL PROTECTED]  wrote:
 km wrote: Hi all, is true parallelism possible in python ? or atleast in the coming versions ? is global interpreter lock a bane in this context ?
 No; maybe; and currently, not usually. On a uniprocessor system, the GIL is no problem. On multi- processor/core systems, it's a big loser.I rather suspect it's a bigger winner there.
Someone who needs to execute Python instructions in parallelis out of luck, of course, but that has to be a small crowd.I would have to assume that in most applications that needthe kind of computational support that implies, are doing most
of the actual computation in C, in functions that run with thelock released.Rrunnable threads is 1 interpreter, plus Nallow threads C functions, where N is whatever the OS will bear.Meanwhile, the interpreter's serial concurrency limits the
damage.The unfortunate reality is that concurrency is abane, so to speak -- programming for concurrency takes skilland discipline and a supportive environment, and Python'sinterpreter provides a cheap and moderately effective support
that compensates for most programmers' unrealistic assessmentof their skill and discipline.Not that you can't go wrong,but the chances you'll get nailed for it are greatly reduced -especially in an SMP environment.
 Donn Cave, [EMAIL PROTECTED] --http://mail.python.org/mailman/listinfo/python-list 
-- Gregory PiñeroChief Innovation OfficerBlended Technologies(www.blendedtechnologies.com)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: A script to run all of my project's pyunit tests

2005-08-19 Thread travislspencer
[EMAIL PROTECTED] wrote:
 for file in glob(projHome + /tests/*.py):
 start = file.rfind(/) + 1
 end = file.rfind(.)
 moduleName = file[start:end]
 module = __import__(moduleName)

  klass = module.__dict__[module.__name__]
  tests.append(unittest.makeSuite(klass, test))

 allTests = unittest.TestSuite(tests)
 runner = unittest.TextTestRunner(verbosity=2)

 runner.run(allTests)

This is still a kludge, but a different and less annoying one.  It
works as long as the TestCase class and module have the same name.

Back to the drawing board...

--
 
Regards,

Travis Spencer

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


Re: Idempotent XML processing

2005-08-19 Thread Will McCutchen
 Read up on XML canonicalization (abrreviated as c14n). lxml implements
 this, also xml.dom.ext.c14n in PyXML. You'll need to canonicalize on
 both ends before hashing.

I said normalization but I think canonicalization is the word I was
looking for.  I wasn't aware that lxml implented it (or that it had an
abbreviation), so that's good to know.  Thanks!


Will.

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


Re: while c = f.read(1)

2005-08-19 Thread [EMAIL PROTECTED]
Alright, everyone seems to have gone off on a tangent here, so I'll try
to stick to your code...

This is what I would ideally like:


  f = open(blah.txt, r)
  while c = f.read(1):
  # ... work on c


But I get a syntax error.


while c = f.read(1):
   ^
SyntaxError: invalid syntax



That's because you are using an assignment operator instead of a
comparison operator. It should have been written like this:

while c == f.read(1):

that would be written correctly, though I don't think that is your
intention.
Try this novel implementation, since nobody has suggested it yet.
-
import mmap

f  = open(blah.txt, 'r+') #opens file for read/write
c = mmap.mmap(f.fileno(),0) #maps the file to be used as memory map...

while c.tell()  c.size():
print c.read_byte()
---
That accomplishes the same thing.

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


Re: Confused newbie needs help with __init__() takes exactly 11 arguments (1 given)

2005-08-19 Thread [EMAIL PROTECTED]
d'oh I'm an idiot... you are making a 'list' object.

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


wanna stop by my homemade glory hole?

2005-08-19 Thread Lacy
my husband is installing an extra bathroom poolside.  there is a perfect size 
hole (unless you have a huge cock) to stick your dick through into the adjoing 
room.  come around the side of my house(perfect if you look like a repair man) 
enter into the unfisnished bathroom and I'll service you from the other side.  
you can leave when your done, no talking or small talk.  i want to do this 
before the hole gets patched up. its been a huge fantasy of mine ever since 
I've seen a glory hole online. you can email me for a time convienient for you. 
im home all-day most days so my schedule is open. do you prefer a certain color 
of lipstick? check out my pic and email here under kallegirl26 
www.no-strings-fun.net/kallegirl26 
ready and waiting, me ;o)


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


Re: How to get a unique id for bound methods?

2005-08-19 Thread Benji York
Russell E. Owen wrote:
 The id of two different methods of the same object seems to be the 
 same, and it may not be stable either.

Two facts you're (apparently) unaware of are conspiring against you:

1) the id of an object is consistent for the lifetime of the object, 
but may be reused after the object goes away

2) methods are bound on an as-needed basis and then normally discarded 
(unless you do something to keep them around)

An illustration:

class cls(object):
   def meth1(self):
 pass
   def meth2(self):
 pass

c = cls()
m1 = c.meth1
print id(m1)
-1209779308
m2 = c.meth1
print id(m2)
-1209652732

 I guess that just means bound methods aren't objects in their own right, 
 but it surprised me.

Nope, they're objects, they just don't tend to be around very long.

 The hash function looks promising -- it prints out consistent values 
 if I use it instead of id in the code above. Is it stable and unique? 
 The documentation talks about objects again, which given the behavior 
 of id makes me pretty nervous.
 
 Any advice would be much appreciated.

I think you'll get the best advice from this group if you tell us what 
the larger problem is that you're trying to solve.
--
Benji York

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


Re: How to get a unique id for bound methods?

2005-08-19 Thread Bengt Richter
On Fri, 19 Aug 2005 13:29:19 -0700, Russell E. Owen [EMAIL PROTECTED] wrote:

I have several situations in my code where I want a unique identifier 
for a method of some object (I think this is called a bound method). I 
want this id to be both unique to that method and also stable (so I can 
regenerate it later if necessary).


I thought the id function was the obvious choice, but it doesn't seem to 
work. The id of two different methods of the same object seems to be the 
same, and it may not be stable either. For instance:

The id function works, but you are applying it to transient objects, which
is what bound methods are unless you cause them to persist one way or another.

class cls(object):
  def __init__(self):
print id(self.meth1)
print id(self.meth2)
  def meth1(self):
pass
  def meth2(self):
pass

c = cls()
3741536
3741536
This means that self.meth1 only existed long enough to be passed to id,
and when id was done with determining its id, self.meth1 was freed.
Then self.meth2 was created, and happened to use a representation space
with the same id as was used for self.meth1. If the two objects (bound methods
here) existed at the same time, they would be guaranteed not to have the same id
unless they were actually the same object.

print id(c.meth1)
3616240
print id(c.meth2)
3616240
This happened to re-use a representation space with another id.

I guess that just means bound methods aren't objects in their own right, 
but it surprised me.
No, they are objects in their own right. You were surprised by your
[mis]interpretation of the above results ;-)

The hash function looks promising -- it prints out consistent values 
if I use it instead of id in the code above. Is it stable and unique? 
The documentation talks about objects again, which given the behavior 
of id makes me pretty nervous.

Any advice would be much appreciated.

If you want a particular bound method to have a stable and persistent id,
make it persist, e.g.,

  class cls(object):
 ...   def __init__(self):
 ... print id(self.meth1)
 ... print id(self.meth2)
 ...   def meth1(self):
 ... pass
 ...   def meth2(self):
 ... pass
 ...
  c = cls()
 49219060
 49219060
  print id(c.meth1)
 49219020
  print id(c.meth2)
 49219020

Ok, those were transient, now nail a couple of bound methods down:
  cm1 = c.meth1
  cm2 = c.meth2

And you can look at their id's all you like:

  print id(cm1)
 49219020
  print id(cm2)
 49219060
  print id(cm1)
 49219020
  print id(cm2)
 49219060

But every time you just evaluate the attribute expression c.meth1 or c.meth2
you will get a new transient bound method object, with a new id:

  print id(c.meth1)
 49219180
  print id(c.meth2)
 49219180

But the ones we forced to persist by binding the expression values to cm1 and 
cm2
above still have the same ids as before:

  print id(cm1)
 49219020
  print id(cm2)
 49219060

So the question would be, why do you (think you ;-) need ids for
these bound methods as such? I.e., what is the situation in your code?

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python jobs (was Re: Python for Webscripting (like PHP))

2005-08-19 Thread Aahz
In article [EMAIL PROTECTED],
Erik Max Francis  [EMAIL PROTECTED] wrote:
Peter Decker wrote:

 Then start looking for telecommuting people. There are lots of us who
 can use work and have excellent telecommuting references, but who
 don't happen to live in a major metro area!

And then there's some in the Bay Area who wouldn't mind telecommuting, 
either ... :-)

We do a *lot* of telecommuting.  I'm working from home today, for
example, because I needed to deal with the plumber.  And we have two
people in Seattle out of seven fulltime people.  However, it's our
experience that people are more productive when they show up at the
office regularly -- the two Seattle people had lots of experience with
our product before they worked independently, and the two of them do
share an office.

(They work across the street from Elliott Bay Books, the bastards.)
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

The way to build large Python applications is to componentize and
loosely-couple the hell out of everything.
-- 
http://mail.python.org/mailman/listinfo/python-list


trying to check the creation date of a file

2005-08-19 Thread David Fickbohm
People,

I am trying to determine the creation date of files in a folder. 
I am using the following code to find the folder and confirm that files
exist in the folder.  If someone could give me an idea how to check a
creation date it would be appreciated.
Thanks
dave

def delete_old_files  (t:\dm\~\users)
# find files and delete files created more than XX number of days
ago 
update_exist = 0

input_dir = t:\dm\~\users\.yy\

if os.path.exists (input_dir) :
files = os.listdir (input_dir)
else:
print Unable to find input file dir: %s !!! % input_dir
sys.exit(2)

if len(files):
for file in files :

file = os.path.join(input_dir) #all files in output
directory will be csv or xls, can be deleted if old enough   

if os.path.isfile(file):   #need to check ext not file, file
name changes each day
if re.search(t:\dm\~\users\x\) and  #creation date
gt x number of days ago 
t:\dm\~\users\davef.input_list.delete(file)

file_delete = 1

if file_delete:

print \n file deleted: \n%s %
str(t:\dm\~\users\x.input_list)

return file_delete 

Dave Fickbohm
Data Mining Analyst
Homegain+
1250 45th St.
Emeryville, CA, 94608
Phone 510 594 4151 - Voice
  510 655 0848 - Fax


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


looking to GIVE my first oral favor

2005-08-19 Thread allie
im new to this, i guess you can say im still curious about having extra marital 
lovers.  i've only had 1 encounter with a married man and I loved it so much.  
its such a strong burning desire now.  when I look at men, i'm always wondering 
how they look nude, or their cock size. basically, i want to find a man to have 
his way with me and really show me the ropes of being a lover to another man on 
the side. exchange face and cock pics with me here under luvnlady3050 
http://www.no-strings-fun.net/kallegirl26 
kisses, me



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


Re: trying to check the creation date of a file

2005-08-19 Thread Larry Bates
use os.stat docs are here:
http://docs.python.org/lib/module-stat.html

Larry Bates

David Fickbohm wrote:
 People,
 
 I am trying to determine the creation date of files in a folder. 
 I am using the following code to find the folder and confirm that files
 exist in the folder.  If someone could give me an idea how to check a
 creation date it would be appreciated.
 Thanks
 dave
 
 def delete_old_files  (t:\dm\~\users)
 # find files and delete files created more than XX number of days
 ago 
 update_exist = 0
 
 input_dir = t:\dm\~\users\.yy\
 
 if os.path.exists (input_dir) :
 files = os.listdir (input_dir)
 else:
 print Unable to find input file dir: %s !!! % input_dir
 sys.exit(2)
 
 if len(files):
 for file in files :
 
 file = os.path.join(input_dir) #all files in output
 directory will be csv or xls, can be deleted if old enough   
 
 if os.path.isfile(file):   #need to check ext not file, file
 name changes each day
 if re.search(t:\dm\~\users\x\) and  #creation date
 gt x number of days ago 
 t:\dm\~\users\davef.input_list.delete(file)
 
 file_delete = 1
 
 if file_delete:
 
 print \n file deleted: \n%s %
 str(t:\dm\~\users\x.input_list)
 
 return file_delete 
 
 Dave Fickbohm
 Data Mining Analyst
 Homegain+
 1250 45th St.
 Emeryville, CA, 94608
 Phone 510 594 4151 - Voice
   510 655 0848 - Fax
 
 

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


servers in python

2005-08-19 Thread Max
I am writing a Hashcash program in python. Rather than create an email 
client plugin, I have done this thru a proxy server which adds the 
Hashcash before forwarding.

What I want to know is whether this is safe. I currently use this code:

class HashcashServer (smtpd.PureProxy):
 def process_message (self, peer, mailfrom, rcpttos, data):
 if peer[0] in trusted_peers:
 # add Hashcash and forward
 else:
 pass

where trusted_peers is a list of peers that are allowed to use the 
service (it is currently just [localhost]).

Is there risk of any hacking, or of this becoming an open relay?

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


Re: Database of non standard library modules...

2005-08-19 Thread Nigel Rowe
Steve Holden wrote:

 Robert Kern wrote:
 Jon Hewer wrote:
 
Is there an online database of non standard library modules for Python?
 
 
 http://cheeseshop.python.org/pypi
 
 While cheeseshop might resonate with the Monty Python fans I have to say
 I think the name sucks in terms of explaining what to expect. If I ask
 someone where I can find a piece of code and the direct me to the cheese
 shop, I might look for another language.
 
 regards
   Steve

To be fair, it's really the Python Package Index, it just happens to be
stored on a machine called cheeseshop.


-- 
Nigel Rowe
A pox upon the spammers that make me write my address like..
rho (snail) swiftdsl (stop) com (stop) au
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: while c = f.read(1)

2005-08-19 Thread Bengt Richter
On Fri, 19 Aug 2005 16:31:47 +1000, John Machin [EMAIL PROTECTED] wrote:

Bengt Richter wrote:
 On 18 Aug 2005 22:21:53 -0700, Greg McIntyre [EMAIL PROTECTED] wrote:
 
 
I have a Python snippet:

 f = open(blah.txt, r)
 while True:
 c = f.read(1)
 if c == '': break # EOF
 # ... work on c

Is some way to make this code more compact and simple? It's a bit
spaghetti.

This is what I would ideally like:

 f = open(blah.txt, r)
 while c = f.read(1):
 # ... work on c

 
 How about (untested):
 
for c in iter((lambda f=open('blah.txt', 'r'): f.read(1)), ''):
# ... work on c
 
:-)
Bengt, did you read on to the bit where the OP wanted to do it more 
nicely? YMMV, but I think you've strayed into pas devant les enfants 
territory.
(-:

LOL. Mais non ;-) OTOH, I think this might cross the line:

f = open('blah.txt')
while [c for c in [f.read(1)] if c!='']:
# ... work on c

;-)

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: while c = f.read(1)

2005-08-19 Thread John Machin
[EMAIL PROTECTED] wrote:
 Alright, everyone seems to have gone off on a tangent here, so I'll try
 to stick to your code...
 
 This is what I would ideally like:
 
 
   f = open(blah.txt, r)
   while c = f.read(1):
   # ... work on c
 
 
 But I get a syntax error.
 
 
 while c = f.read(1):
^
 SyntaxError: invalid syntax
 
 
 
 That's because you are using an assignment operator instead of a
 comparison operator. It should have been written like this:
 
 while c == f.read(1):
 
 that would be written correctly, though I don't think that is your
 intention.
 Try this novel implementation, since nobody has suggested it yet.
 -
 import mmap
 
 f  = open(blah.txt, 'r+') #opens file for read/write
 c = mmap.mmap(f.fileno(),0) #maps the file to be used as memory map...
 
 while c.tell()  c.size():
 print c.read_byte()
 ---
 That accomplishes the same thing.
 

Dear Sir or Madam,
I refer you to your recent post -- the one that started with d'oh.
Regards,
John
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wanna stop by my homemade glory hole?

2005-08-19 Thread Stephen Kellett
 wanna stop by my homemade glory hole?

I don't think anyone on this group will be interested in trying their 
Python with that. Take it somewhere else.
-- 
Stephen Kellett
Object Media Limitedhttp://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python jobs (was Re: Python for Webscripting (like PHP))

2005-08-19 Thread Terry Reedy

Gregory Piñero [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
I'd love Python work, just like everyone else here.  On a related topic, 
what's the policy/etiquette of posting a resume on here, or mentioning 
what kind of work you're looking for?

I would take absence of such postings, even though you can imagine *lots* 
of people have had the same idea, as an indication that it is against 
policy/etiquette.  If 1 person does it, we could easily have 10 or 100 a 
day ;-).

  And what's the policy in general for most newsgroups and mailing lists?

For mainline newsgroups, such as the comp.*, commercial annoucements are 
generally counter-indicated unless the name (.marketplace) or charter say 
otherwise.  Exceptions would be a low volume of things of direct and narrow 
interest.  So I consider the rare job announcements posted here ok.  The 
same for book announcements.  In either case, such are positive news for 
what is still a minority, just becoming mainstream, language.

Terry J. Reedy



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

Re: How to get a unique id for bound methods?

2005-08-19 Thread Paolino
Russell E. Owen wrote:

 The hash function looks promising -- it prints out consistent values 
 if I use it instead of id in the code above. Is it stable and unique? 
 The documentation talks about objects again, which given the behavior 
 of id makes me pretty nervous.
 
I dont know how the hash of a bound method is calculated,but as the 
function of the method is a stable and referenced object and as 
instances lives are in your hands,then an id(self)^id(self.meth.im_func) 
should be a chance for that 'hash' function.

def methodId(boundMethod):
   return id(boundMethod.im_self)^id(boundMethod.im_func)

class cls(object):
   def __init__(self):
 print methodId(self.meth1)
 print methodId(self.meth2)
   def meth1(self):
 pass
   def meth2(self):
 pass

c = cls()
print methodId(c.meth1)
print methodId(c.meth2)

I think this is giving what you expected.

Regards Paolino





___ 
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
http://mail.yahoo.it
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie Question

2005-08-19 Thread John Machin
Tom Strickland wrote:
 I have a file that contains many lines, each of which consists of a string 
 of comma-separated variables, mostly floats but some strings. Each line 
 looks like an obvious tuple to me. How do I save each line of this file as a 
 tuple rather than a string? Or, is that the right way to go?
 
 Thank you.
 
 Tom Strickland 
 
 

You will probably be able to read the file using the csv module.

But what do you want to do with the data? Transcribe it into some other 
format just for a learning exercise?  What do you mean by save as tuple?

A few more clues might save you from being (a) ignored and/or (b) 
deluged with irrelevant responses from well-intentioned wanting-to-help 
people who have guessed wrongly what you are rabbiting on about ...

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


Re: stdin - stdout

2005-08-19 Thread John Machin
limodou wrote:
 2005/8/19, max(01)* [EMAIL PROTECTED]:
 
hi.

i was wondering, what's the simplest way to echo the standard input to
the standard output, with no modification.

i came up with:

...
while True:
   try:
 raw_input()
   except EOFError:
 break
...

but i guess there must be a simpler way.

using bash i simply do 'cat', *sigh*!

bye

max

ps: in perl you ca do this:

...
while ($line = STDIN)
   {
 print STDOUT ($line);
   }
...
 
 
 Try this.
 
 import sys
 
 line = sys.stdin.readline()
 while line:
 sys.stdout.write(line)
 line = sys.stdin.readline()
 

Try this:

import sys
for line in sys.stdin:
sys.stdout.write(line)



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


Re: global interpreter lock

2005-08-19 Thread Bryan Olson
Donn Cave wrote:
   Bryan Olson wrote:
 On a uniprocessor system, the GIL is no problem. On multi-
 processor/core systems, it's a big loser.
 
 
  I rather suspect it's a bigger winner there.
 
  Someone who needs to execute Python instructions in parallel
  is out of luck, of course, but that has to be a small crowd.

Today, sure. The chip guys have spoken and the future is mult-
core.

  I would have to assume that in most applications that need
  the kind of computational support that implies, are doing most
  of the actual computation in C, in functions that run with the
  lock released.

That seems an odd thing to assume.

  Rrunnable threads is 1 interpreter, plus N
  allow threads C functions, where N is whatever the OS will bear.
 
  Meanwhile, the interpreter's serial concurrency limits the
  damage.  The unfortunate reality is that concurrency is a
  bane, so to speak -- programming for concurrency takes skill
  and discipline and a supportive environment, and Python's
  interpreter provides a cheap and moderately effective support
  that compensates for most programmers' unrealistic assessment
  of their skill and discipline.  Not that you can't go wrong,
  but the chances you'll get nailed for it are greatly reduced -
  especially in an SMP environment.

I don't see much point in trying to convince programmers that
they don't really want concurrent threads. They really do. Some
don't know how to use them, but that's largely because they
haven't had them. I doubt a language for thread-phobes has much
of a future.


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


Karrigell tutorial published

2005-08-19 Thread Luis M. Gonzalez
Karrigell has new tutorial here:
http://karrigell.sourceforge.net/en/tutorial.html

For those who don't know what Karrigell is, I'd just say that it is the
most pythonic, simple, fun, straightforward and full-featured web
framework available today.

Check it out! http://karrigell.sourceforge.net/

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


Re: How to get a unique id for bound methods?

2005-08-19 Thread Russell E. Owen
In article [EMAIL PROTECTED],
 Benji York [EMAIL PROTECTED] wrote:

Russell E. Owen wrote:
 The id of two different methods of the same object seems to be the 
 same, and it may not be stable either.

Two facts you're (apparently) unaware of are conspiring against you:

1) the id of an object is consistent for the lifetime of the object, 
but may be reused after the object goes away

2) methods are bound on an as-needed basis and then normally discarded 
(unless you do something to keep them around)

Thank you and Bengt Richter. You both explained it very well.

The current issue is associated with Tkinter. I'm trying to create a tk 
callback function that calls a python function (any python callable 
entity).

To do that, I have to create a name for tk that is unique to my python 
function. A hash-like name would be perfect, meaning a name that is 
always the same for a particular python function and always different 
for a different python function. That would save a lot of housekeeping.

Does the built-in hash function actually do the job?

If I centralize all tk callback management and keep objects that 
represent the tk callback around then I can avoid the whole issue. I was 
hoping to avoid that, because it complicates housekeeping and adds a 
risk of memory leaks (at least I think so; right now tk deallocates its 
callback functions in the few cases I care about so I don't worry about 
it.)

-- Russell

P.S. Paolino: thank you also for your kind reply. Your suggestion sounds 
very useful if I only want a hash for a bound function, but in this case 
since I want a hash for any callable entity I'm not sure it'll work.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickle.load not working?

2005-08-19 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED],
[EMAIL PROTECTED] wrote:

 oh, well how do I make derek be an instance of 'chatuser' ?

Spot the difference::

 In [228]: class A: pass
.228.:

 In [229]: a = A

 In [230]: repr(a)
 Out[230]: 'class __main__.A at 0x4078883c'

 In [231]: b = A()

 In [232]: repr(b)
 Out[232]: '__main__.A instance at 0x4075e52c'

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trying to check the creation date of a file

2005-08-19 Thread John Machin
David Fickbohm wrote:
 People,
 
 I am trying to determine the creation date of files in a folder. 
 I am using the following code to find the folder and confirm that files
 exist in the folder.

Presumably you meant intend to use the following pseudocode (not am 
using the following code)  -- many of the statements (marked XXX below) 
are just not valid Python.

  If someone could give me an idea how to check a
 creation date it would be appreciated.
 Thanks
 dave
 
 def delete_old_files  (t:\dm\~\users)
XXX
 # find files and delete files created more than XX number of days
 ago 
 update_exist = 0
Did you mean file_delete = 0?

 
 input_dir = t:\dm\~\users\.yy\
XXX
 
 if os.path.exists (input_dir) :
 files = os.listdir (input_dir)
 else:
 print Unable to find input file dir: %s !!! % input_dir
 sys.exit(2)
 
 if len(files):
Not necessary -- for file in files does nothing gracefully if files is 
empty. If it were necessary, if not files: is suggested as an 
alternative to if len(files).
 for file in files :
 
 file = os.path.join(input_dir) #all files in output
 directory will be csv or xls, can be deleted if old enough   

I think you mean file = os.path.join(input_dir, file)

 
 if os.path.isfile(file):   #need to check ext not file, file
 name changes each day
 if re.search(t:\dm\~\users\x\) and  #creation date
XXX
You don't need the re module to check if the file's extension is csv 
or xls


 gt x number of days ago 
 t:\dm\~\users\davef.input_list.delete(file)
XXX
 
 file_delete = 1
 
 if file_delete:
 
 print \n file deleted: \n%s %
 str(t:\dm\~\users\x.input_list)
 
 return file_delete 

Now, to answer your question: You have obviously read the docs on the os 
module; what did you not understand about os.stat()?

I suggest you contemplate the following real-not-pseudo-code and then 
examine the relevant sections of the docs for os.stat(), the stat 
module, and the time module.

C:\junktype st_ctime.py
import os, stat, time

def get_create_time(path):
 int_time = os.stat(path)[stat.ST_CTIME]
 str_time = time.ctime(int_time)
 return str_time

if __name__ == __main__:
 import glob, sys
 for arg in sys.argv[1:]:
 for path in glob.glob(arg):
 create_time = get_create_time(path)
 print path, create_time
C:\junkst_ctime.py *c*.py
checkmodules.py Fri Jun 24 22:32:57 2005
ivancodecs.py Mon Jul 11 10:03:23 2005
st_ctime.py Sat Aug 20 09:22:00 2005

C:\junk
-- 
http://mail.python.org/mailman/listinfo/python-list


wanna stop by my homemade glory hole?

2005-08-19 Thread Steph
my husband is installing an extra bathroom poolside.  there is a perfect size 
hole (unless you have a huge cock) to stick your dick through into the adjoing 
room.  come around the side of my house(perfect if you look like a repair man) 
enter into the unfisnished bathroom and I'll service you from the other side.  
you can leave when your done, no talking or small talk.  i want to do this 
before the hole gets patched up. its been a huge fantasy of mine ever since 
I've seen a glory hole online. you can email me for a time convienient for you. 
im home all-day most days so my schedule is open. do you prefer a certain color 
of lipstick? check out my pic and email here under kallegirl26 
www.no-strings-fun.net/kallegirl26 
ready and waiting, me ;o)


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


Re: How to get a unique id for bound methods?

2005-08-19 Thread Bengt Richter
On Fri, 19 Aug 2005 16:33:22 -0700, Russell E. Owen [EMAIL PROTECTED] wrote:
[...]

The current issue is associated with Tkinter. I'm trying to create a tk 
callback function that calls a python function (any python callable 
entity).

To do that, I have to create a name for tk that is unique to my python 
function. A hash-like name would be perfect, meaning a name that is 
always the same for a particular python function and always different 
for a different python function. That would save a lot of housekeeping.

Why do you need a name? Can you post an example snippet that shows
a callback function being used with Tkinter as you would wish?
I have a feeling there is a much simpler solution than you are imagining ;-)

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Version of TAR in tarfile module? TAR 1.14 or 1.15 port to Windows?

2005-08-19 Thread Claudio Grondi
I need to unpack on a Windows 2000 machine
some Wikipedia media .tar archives which are
compressed with TAR 1.14 (support for long file
names and maybe some other features) .
It seems, that Pythons tarfile module is able to list far
more files inside the archives than WinRAR or 7zip or
TotalCommander, but will it unpack all available files
(largest archive size 17 GByte)?

If tarfile is build on TAR 1.14 or TAR 1.15 it will be
probably ok, so my questions are:

What TAR version is built into the tarfile module?

Is there a TAR 1.14 or 1.15 port to Windows
available in Internet for download (which URL)?

Claudio



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


Re: Moinmoin config

2005-08-19 Thread Mark
The missing link under /var/www/html was exactly the problem.  Somehow
missed this in the labyrinth of setup instructions.

I have another question, and as of yet, have not found another
discussion group for moinmoin, so sorry, but here goes:

I have a table and would like the table borders to go away.  Although
it doesn't talk about border widths explicitliy, the HelpOnTables seems
to point to this :

tablestyle=width: 80%; border: 0;

But that does nothing to the border lines.  Adjusting width in the same
line does work to change the size of the table, but it doesn't seem to
understand 'border'.

Anyone know how to make the borders disappear?

Thanks
Mark

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


Re: Python jobs

2005-08-19 Thread Mike Meyer
Terry Reedy [EMAIL PROTECTED] writes:
 generally counter-indicated unless the name (.marketplace) or charter say 
 otherwise.  Exceptions would be a low volume of things of direct and narrow 
 interest.  So I consider the rare job announcements posted here ok.  The 
 same for book announcements.

The key words here are of direct and narrow interest. Job postings
that don't mention Python in c.l.python are spam, nothing else.

Maybe the Python jobs lists needs a available developers
counterpart? Or would it be to big/dynamic to maintain using whatever
is behind the jobs list?

   mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: global interpreter lock

2005-08-19 Thread Mike Meyer
Bryan Olson [EMAIL PROTECTED] writes:
 I don't see much point in trying to convince programmers that
 they don't really want concurrent threads. They really do. Some
 don't know how to use them, but that's largely because they
 haven't had them. I doubt a language for thread-phobes has much
 of a future.

The real problem is that the concurrency models available in currently
popular languages are still at the goto stage of language
development.  Better models exist, have existed for decades, and are
available in a variety of languages.

It's not that these languages are for thread-phobes, either. They
don't lose power any more than Python looses power by not having a
goto. They languages haven't taken off for reasons unrelated to the
threading model(*).

The rule I follow in choosing my tools is Use the least complex tool
that will get the job done.  Given that the threading models in
popular languages are complex and hard to work with, I look elsewhere
for solutions. I've had good luck using async I/O in lieue of
theards. It's won't solve every problem, but where it does, it's much
simpler to work with.

mike

*) I recently saw a discussion elsehwere that touched on almost the
same topic, lamenting that diagnostic tools in popular programming
languages pretty much sucked, being at best no better than they were
30 years ago. The two together seem to indicate that something is
fundamentally broken somewhere.
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Save Binary data.

2005-08-19 Thread Mike Meyer
Larry Bates [EMAIL PROTECTED] writes:

 Directories with large numbers of files was a problem in FAT16 and
 FAT32 filesystems but not really a problem in NTFS or Linux (at
 least that I've found).

Depends on how you define large and what Linux file system you're
using. Of course, if you open the directory in a GUI directory
browser, you're probably going to be unhappy no matter what the
underlying file system.

The standard Unix solution to this is to break the files out into
subdirectories. Create a subdirectory with the name being the first
few letters of the file name, and then store the file in that
subdirectory. Easy to do programmatically, it's still easy to find
files by hand, and you can make it as fine-grained as you want.

  mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python jobs

2005-08-19 Thread Aahz
In article [EMAIL PROTECTED], Mike Meyer  [EMAIL PROTECTED] wrote:

Maybe the Python jobs lists needs a available developers
counterpart? Or would it be to big/dynamic to maintain using whatever
is behind the jobs list?

Part of the reason the Jobs page hasn't moved to a wiki is that often
people sending in job ads are insufficiently technical to handle the
formatting.  That presumably wouldn't be true for an available
developers wiki...
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

The way to build large Python applications is to componentize and
loosely-couple the hell out of everything.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: BeautifulSoup

2005-08-19 Thread Mike Meyer
Paul McGuire [EMAIL PROTECTED] writes:

 Here's a pyparsing program that reads my personal web page, and spits
 out HTML with all of the HREF's reversed.

Parsing HTML isn't easy, which makes me wonder how good this solution
really is. Not meant as a comment on the quality of this code or
PyParsing, but as curiosity from someone who does a lot of [X}HTML
herding.

 -- Paul
 (Download pyparsing at http://pyparsing.sourceforge.net.)

If it were in the ports tree, I'd have grabbed it and tried it
myself. But it isn't, so I'm going to be lazy and ask. If PyParsing
really makes dealing with HTML this easy, I may package it as a port
myself.

 from pyparsing import Literal, quotedString
 import urllib

 LT = Literal()
 GT = Literal()
 EQUALS = Literal(=)
 htmlAnchor = LT + A + HREF + EQUALS +
 quotedString.setResultsName(href) + GT

 def convertHREF(s,l,toks):
 # do HREF conversion here - for demonstration, we will just reverse
 them
 print toks.href
 return A HREF=%s % toks.href[::-1]

 htmlAnchor.setParseAction( convertHREF )

 inputURL = http://www.geocities.com/ptmcg;
 inputPage = urllib.urlopen(inputURL)
 inputHTML = inputPage.read()
 inputPage.close()

 print htmlAnchor.transformString( inputHTML )

How well does it deal with other attributes in front of the href, like
A onClick=... href=...?

How about if my HTML has things that look like HTML in attributes,
like TAG ATTRIBUTE=stuffA HREF=stuff?

 Thanks,
 mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Moinmoin config

2005-08-19 Thread mbstevens
Mark wrote:
 The missing link under /var/www/html was exactly the problem.  Somehow
 missed this in the labyrinth of setup instructions.
 
 I have another question, and as of yet, have not found another
 discussion group for moinmoin, so sorry, but here goes:
 
 I have a table and would like the table borders to go away.  Although
 it doesn't talk about border widths explicitliy, the HelpOnTables seems
 to point to this :
 
 tablestyle=width: 80%; border: 0;
 
 But that does nothing to the border lines.  Adjusting width in the same
 line does work to change the size of the table, but it doesn't seem to
 understand 'border'.
 
 Anyone know how to make the borders disappear?
 
 Thanks
 Mark
 
I would try a stylesheet forum or an (X)HTML forum for this 
question, but first look here,

http://lynx.fnal.gov/runjob/HelpOnConfiguration/CascadingStyleSheets

and then look here,

http://www.w3.org/TR/REC-CSS2/tables.html#borders

But, if the information you're putting in the table is not
true tabular data, consider more semantic markup.
--
mbstevens
http://www.mbstevens.com/cgi/mkatt.pl?name=python/Critique_Generator

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


ANN: Binary Distribution of pyMinGW-241

2005-08-19 Thread A.B., Khalid
This is to inform those interested in Python and MinGW that a binary
distribution of pyMinGW-241 is now available. This is mainly a
packaging of the March release in binary form for those who are finding
it difficult to build Python or its standard extensions in MinGW.


WHAT'S INSIDE
-
- pyMinGW-License
- pyMinGW-Readme
- Python-License
- python.exe
- python24.dll
- pythonw.exe
- w9xpopen.exe
- python_icon.exe
+ Dlls:
  - tcl84.dll
  - tclpip84.dll
  - tk84.dll
  - zlib.pyd
  - _bsddb.pyd
  - _socket.pyd (Without IPv6 support, as MinGW still lacks it)
  - _ssl.pyd
  - _testcapi.pyd
  - _tkinter.pyd
  - bz2.pyd
  - pyexpat.pyd
  - select.pyd
  - unicodedata.pyd
  - winsound.pyd
+ Include:
  pyconfig.h
+ Lib:
  + distutils
+ command
  - build_ext.py
- ccompiler.py
- cygwinccompiler.py
- unixccompiler.py
+ Libs:
  - libpython24.a
+ tcl:
  + tcl84
  + tk84



Get it from here:
http://jove.prohosting.com/iwave/ipython/pyMinGW.html


Regards
Khalid

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


Well, another try Re: while c = f.read(1)

2005-08-19 Thread en.karpachov
On 18 Aug 2005 22:21:53 -0700
Greg McIntyre wrote:

   f = open(blah.txt, r)
   while True:
   c = f.read(1)
   if c == '': break # EOF
   # ... work on c
 
 Is some way to make this code more compact and simple? It's a bit
 spaghetti.
 
 This is what I would ideally like:
 
   f = open(blah.txt, r)
   while c = f.read(1):
   # ... work on c

for data in iter(lambda:f.read(1024), ''):
 for c in data:
  # ... work on c

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


[ python-Bugs-1264168 ] PyArg_ParseTupleAndKeywords doesn't handle I format correctl

2005-08-19 Thread SourceForge.net
Bugs item #1264168, was opened at 2005-08-19 19:31
Message generated for change (Comment added) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1264168group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: None
Status: Closed
Resolution: Duplicate
Priority: 5
Submitted By: John Finlay (finlay648)
Assigned to: Nobody/Anonymous (nobody)
Summary: PyArg_ParseTupleAndKeywords doesn't handle I format correctl

Initial Comment:
PyArg_ParseTupleAndKeywords fails with the message;
...impossiblebad format char
when parsing an optional keyword param using I format.

Using Python 2.3.5 but also observed in Python 2.4.x

The problem is a missing I handler in the skipitem
function.

I've attached a proposed patch.

--

Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-08-19 20:18

Message:
Logged In: YES 
user_id=1188172

Duplicate of #893549. See patch #1212928 to fix all missing
format codes.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1264168group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



<    1   2