Re: Regular Expressions

2007-02-10 Thread John Machin
On Feb 11, 10:26 am, Geoff Hill [EMAIL PROTECTED] wrote:
 What's the way to go about learning Python's regular expressions? I feel
 like such an idiot - being so strong in a programming language but knowing
 nothing about RE.

I suggest that you work through the re HOWTO
http://www.amk.ca/python/howto/regex/
and by work through, I don't mean read. I mean as each new concept
is introduced:
1. try the given example(s) yourself at the interactive prompt
2. try variations on the examples
3. read the relevant part of the Library Reference Manual

Also I'd suggest reading threads in this newsgroup where people are
asking for help with re.

HTH,
John

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


Re: Hacking in python

2007-02-10 Thread Geoff Hill
The word hack can be known as a smart/quick fix to a problem. 


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


Re: Regular Expressions

2007-02-10 Thread Paul Rubin
John Machin [EMAIL PROTECTED] writes:
  What's the way to go about learning Python's regular expressions? I feel
  like such an idiot - being so strong in a programming language but knowing
  nothing about RE.
 
 I suggest that you work through the re HOWTO
 http://www.amk.ca/python/howto/regex/

Also remember Zawinski's law:
http://fishbowl.pastiche.org/2003/08/18/beware_regular_expressions
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.4 pdf Tutorial--Available

2007-02-10 Thread Gabriel Genellina
En Sat, 10 Feb 2007 21:20:43 -0300, W. Watson [EMAIL PROTECTED]  
escribió:

 Gabriel Genellina wrote:
 En Sat, 10 Feb 2007 16:45:08 -0300, W. Watson [EMAIL PROTECTED]
 escribió:

 I was able to download the 2.5 tutorial, but think I may need the 2.4
 tutorial (Guido van Rossum) if it exists. Anyone know where to find it?

 Go to http://docs.python.org/ and follow the link Locate previous
 versions

 Thanks. Found the 2.4 Python Tutorial web page by Guido van Rossum, but
 would like the pdf.

Go to http://docs.python.org/
Click on Locate previous versions
Click on Python 2.4.4 (latest release on the 2.4 series)
Click on Download all these documents
Choose your format (PDF), page size (PDF A4 or PDF Letter), and your  
favorite compression format (Zip or bzip2) and download it.
You get the whole documentation in the chosen format, not only the  
tutorial.
On that same page, it says: These documents are not available for  
download individually.

-- 
Gabriel Genellina

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


Re: Python 2.4 pdf Tutorial--Available

2007-02-10 Thread W. Watson
Gabriel Genellina wrote:
 En Sat, 10 Feb 2007 21:20:43 -0300, W. Watson [EMAIL PROTECTED] 
 escribió:
 
 Gabriel Genellina wrote:
 En Sat, 10 Feb 2007 16:45:08 -0300, W. Watson [EMAIL PROTECTED]
 escribió:

 I was able to download the 2.5 tutorial, but think I may need the 2.4
 tutorial (Guido van Rossum) if it exists. Anyone know where to find it?

 Go to http://docs.python.org/ and follow the link Locate previous
 versions

 Thanks. Found the 2.4 Python Tutorial web page by Guido van Rossum, but
 would like the pdf.
 
 Go to http://docs.python.org/
 Click on Locate previous versions
 Click on Python 2.4.4 (latest release on the 2.4 series)
 Click on Download all these documents
 Choose your format (PDF), page size (PDF A4 or PDF Letter), and your 
 favorite compression format (Zip or bzip2) and download it.
 You get the whole documentation in the chosen format, not only the 
 tutorial.
 On that same page, it says: These documents are not available for 
 download individually.
 
 --Gabriel Genellina
 
Thanks again. I may get the hang of this eventually. It looks like a pattern 
is developing. :-)


  Wayne T. Watson (Watson Adventures, Prop., Nevada City, CA)
  (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
   Obz Site:  39° 15' 7 N, 121° 2' 32 W, 2700 feet

   Humans aren't the first species to alter the atmosphere; that
distinction belongs to early bacteria, which some two billion
years ago, invented photosynthesis.
 -- Field Notes from a Catastrophe, Kolbert

-- 
 Web Page: home.earthlink.net/~mtnviews
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Regular Expressions

2007-02-10 Thread gregarican
On Feb 10, 6:26 pm, Geoff Hill [EMAIL PROTECTED] wrote:
 What's the way to go about learning Python's regular expressions? I feel
 like such an idiot - being so strong in a programming language but knowing
 nothing about RE.

I highly recommend reading the book Mastering Regular Expressions,
which I believe is published by O'Reilly. It's a great reference and
helps peel the onion in terms of working through RE. They are a
language unto themselves. A fun brain exercise.

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


Can anyone explain a part of a telnet client code to me..

2007-02-10 Thread Jia Lu
Hello
 I have a program that can telnet to a host.
 But I cannot understand from [for c in data] part, can anyone explain
it to me?
 Thank you very much.

[CODE]


import sys, posix, time
from socket import *

BUFSIZE = 1024

# Telnet protocol characters

IAC  = chr(255) # Interpret as command
DONT = chr(254)
DO   = chr(253)
WONT = chr(252)
WILL = chr(251)

def main():
# Get hostname from param
host = sys.argv[1]
try:
# Get ip from hostname
hostaddr = gethostbyname(host)
except error:
sys.stderr.write(sys.argv[1] + ': bad host name\n')
sys.exit(2)
# Check param[2] as type of protocol
if len(sys.argv)  2:
servname = sys.argv[2]
else:
# default use telnet
servname = 'telnet'
# If got servname as port num
if '0' = servname[:1] = '9':
# cast port num from str to int
port = eval(servname)
else:
try:
# Get port num by service name
port = getservbyname(servname, 'tcp')
except error:
sys.stderr.write(servname + ': bad tcp service name\n')
sys.exit(2)
# Create a tcp socket
s = socket(AF_INET, SOCK_STREAM)
# Connect to server
try:
s.connect((host, port))
except error, msg:
sys.stderr.write('connect failed: ' + repr(msg) + '\n')
sys.exit(1)
# Fork a proccess
pid = posix.fork()
#
if pid == 0:
# child -- read stdin, write socket
while 1:
line = sys.stdin.readline()
s.send(line)
else:
# parent -- read socket, write stdout
iac = 0 # Interpret next char as command
opt = ''# Interpret next char as option
while 1:
data = s.recv(BUFSIZE)
# if recv nothing then Exit program
if not data:
# EOF; kill child and exit
sys.stderr.write( '(Closed by remote host)\n')
# Call posix function kill and send signal 9 to child
posix.kill(pid, 9)
sys.exit(1)
cleandata = ''
for c in data:
if opt:
print ord(c)
s.send(opt + c)
opt = ''
elif iac:
iac = 0
if c == IAC:
cleandata = cleandata + c
elif c in (DO, DONT):
if c == DO: print '(DO)',
else: print '(DONT)',
opt = IAC + WONT
elif c in (WILL, WONT):
if c == WILL: print '(WILL)',
else: print '(WONT)',
opt = IAC + DONT
else:
print '(command)', ord(c)
elif c == IAC:
iac = 1
print '(IAC)',
else:
cleandata = cleandata + c
sys.stdout.write(cleandata)
sys.stdout.flush()


try:
main()
except KeyboardInterrupt:
pass

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


Re: Regular Expressions

2007-02-10 Thread Shawn Milo
On 10 Feb 2007 18:58:51 -0800, gregarican [EMAIL PROTECTED] wrote:
 On Feb 10, 6:26 pm, Geoff Hill [EMAIL PROTECTED] wrote:
  What's the way to go about learning Python's regular expressions? I feel
  like such an idiot - being so strong in a programming language but knowing
  nothing about RE.

 I highly recommend reading the book Mastering Regular Expressions,
 which I believe is published by O'Reilly. It's a great reference and
 helps peel the onion in terms of working through RE. They are a
 language unto themselves. A fun brain exercise.

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


Absolutely: Get Mastering Regular Expressions by Jeffrey Friedl. Not
only is it easy to read, but you'll get a lot of mileage out of
regexes in general. Grep, Perl one-liners, Python, and other tools use
regexes, and you'll find that they are really clever little creatures
once you befriend a few of them.

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


Re: Regular Expressions

2007-02-10 Thread Geoff Hill
Thanks. O'Reilly is the way I learned Python, and I'm suprised that I didn't 
think of a book by them earlier. 


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


Re: unique elements from list of lists

2007-02-10 Thread azrael
no heart feelings. i was just throwing ideas. no time to testing it.


On Feb 9, 3:55 pm, Tekkaman [EMAIL PROTECTED] wrote:
 Thanks everybody!Azrael: your suggestions involve python-level membership 
 testing and
 dummy list construction just like my uniter3 example, so I'm afraid
 they would not go any faster. There's no built-in sequence flattening
 function that I know of btw.
 bearophile: your implementation is very similar to my uniter2
 (subsequent set unions) but without the additional lambda def
 overhead, and in fact it goes faster. Not faster than uniter though.
 Peter: your solution is the fastest, removing the explicit for loop
 resulted in a 30% speed gain. Looks like using set() is a must.

 -- Simone


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


Re: Best Free and Open Source Python IDE

2007-02-10 Thread Kirk Sluder
In article [EMAIL PROTECTED],
 Stef Mientki [EMAIL PROTECTED] wrote:

 Which brings me to some other questions on waste:
 - isn't it a pitty so many people are involved in writing another editor / 
 IDE ?

I don't know about that.  Most of the new editor development appears 
to involve one of the following:

1: Taking advantage of a specific graphical toolkit or interface, 
such as  KDE, Gnome, Cocoa, MS Foundation, SWING, and terminals. 

2: Building around a specific language for macro and script 
programming.  

3: Adding features that are useful for specific development models. 
Web/HTML authoring requires upload tools, C/C++ requires make, Java 
might use Ant, lisp and python can use shells.  

 - isn't it a waste for newbies to evaluate a dozen editors / IDE's ?

I think that in many cases, the choices are constrained to two or 
three depending on what the _newbie_ wants to do, and what Desktop 
Environment they use.  For general editors on OS X, I'd suggest 
Smultron, or TextWrangler.  For KDE, kick the tires on Kate a bit.  
Cross-platform and portable? jEdit.  Text consoles? Emacs, vim or 
jed.

And if the newbie has some specific itch that needs to be scratched, 
there again the choices usually boil down to two or three best of 
breed IDEs, many of which are segregated by platform.  

  just some thoughts,
 of a some months old newbie,
 Stef Mientki
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygame and python 2.5

2007-02-10 Thread [EMAIL PROTECTED]
On Feb 10, 4:07?pm, Ben Sizer [EMAIL PROTECTED] wrote:
 On Feb 10, 6:31 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

  On Feb 9, 11:39?am, Ben Sizer [EMAIL PROTECTED] wrote:

   Hopefully in the future, some of those convoluted steps will be fixed,
   but that requires someone putting in the effort to do so. As is often
   the case with Python, and indeed many open source projects, the people
   who are knowledgeable enough to do such things usually don't need to
   do them, as their setup already works just fine.

  So you're saying the knowledgeable people's attitude
  is fuck everyone else as lomg as it's not MY problem?

  And you people complain about Microsoft.

 Am I one of those people? You don't exactly make it clear.

I'm talking about the people who complain about Microsoft
making the VC6 compiler no longer legally available and
yet are so irresponsible that they use it for the latest
release.


 But yes, there is a lot of well, it works for me going around. If
 you do that long enough, people stop complaining, so people wrongly
 assume there's no longer a problem. This is partly why Python has
 various warts on Windows and why the standard libraries are oddly
 biased, why configuring Linux almost always ends up involving hand-
 editing a .conf file, why the leading cross-platform multimedia
 library SDL still doesn't do hardware graphics acceleration a decade
 after such hardware became mainstream, and so on.

 However, the difference between the open-source people and Microsoft
 is the the open-source people aren't being paid by you for the use of
 their product, so they're not obligated in any way to help you.

This argument has become tiresome. The Python community
wants Python to be a big fish in the big pond. That's why
they make Windows binaries available.

 After all, they have already given freely and generously, and if they choose
 not to give more on top of that, it's really up to them.

Right. Get people to commit and then abandon them. Nice.

 Yes, it's
 occasionally very frustrating to the rest of us, but that's life.

As the Kurds are well aware.

 The best I feel I can do is raise these things on occasion,
 on the off-chance that I manage to catch the attention of
 someone who is
 altruistic, knowledgeable, and who has some spare time on
 their hands!

Someone who, say, solved the memory leak in the GMPY
divm() function even though he had no way of compiling
the source code?

Just think of what such an altruistic, knowedgeable
person could do if he could use the current VC compiler
or some other legally available compiler.


 --
 Ben Sizer


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


favourite editor

2007-02-10 Thread azrael
Since i'm new on this forum, and first time meeting a python comunity,
i wanted to ask you for your python editors.

Im looking for some good python editor, with integrated run function,
without having to set it up manualy like komodo.
I found the pyscripter, and it has all i need, but it's unsatble.
bloated. it crashes when i close an yplication window run by python
from pyscripter. please. tell me a good one with buil in run (-very
important) and nice gui. if possible to suport projects, code
highlighting, code completition, class browser, python comand line
(), traceback.

I didn't take a look on vista (and i dont want to), but i hope they
improved the notepad.

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


os.tmpfile() - permission denied (Win XP)

2007-02-10 Thread John Machin
Hi,

Here's what's happening:

Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win32
Type help, copyright, credits or license for more information.
|  import os
|  os.tmpfile()
Traceback (most recent call last):
  File stdin, line 1, in module
OSError: [Errno 13] Permission denied

but tempfile.mkstemp() works:

 import tempfile
 tempfile.mkstemp()
(3, 'c:\\docume~1\\sjm\\locals~1\\temp\\tmpnfuk9i')

This is Windows XP Pro SP2. The user with the problem is _not_ an
administrator. It works OK when logged on as an administrator. I am
using the mode which enables having multiple users logged on and
switching between them.

The problem happens with Pythons back to 2.2. Python 2.1 on Windows
doesn't seem to have a tmpfile() function in the os module.

On a Windows 2000 SP4 box, with a Power User [part way between
administrator and vanilla user] Python 2.3.5 os.tmpfile() works OK.
AFAICT Win XP doesn't have this intermediate level of user.

Questions:
1. Before I start checking what permissions who has to do what to
which, what directory is it likely to be trying to open the temp file
in? C:\WINDOWS\TEMP?
2. What is the general advice about whether to use os.tmpfile() or the
functions in the tempfile module? I'm presuming that as os.tmpfile()
is ultimately calling tmpfile() in the C stdio library, nobody would
have gone to the effort of making the tempfile module just to
reproduce stdio functionality, but AFAICT there's no guidance in the
docs. Maybe I should be talking to the authors of the package that is
using os.tmpfile() :-)

TIA for any clues,
John

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


Re: pygame and python 2.5

2007-02-10 Thread skip

 However, the difference between the open-source people and Microsoft
 is the the open-source people aren't being paid by you for the use of
 their product, so they're not obligated in any way to help you.

mensanator This argument has become tiresome. The Python community
mensanator wants Python to be a big fish in the big pond. That's why
mensanator they make Windows binaries available.

I suspect the main reason Windows binaries are produced is because a)
Microsoft doesn't ship Python installed on Windows, and b) your garden
variety Windows user doesn't have the tools necessary to build Python from
source.  Not being a Windows user myself I don't understand all the ins and
outs of VC6 v. VC7, legal or technical.  Is there nothing Microsoft could
have done to make VC7 compatible with the existing VC6-based build
procedure?

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


Re: Can anyone explain a part of a telnet client code to me..

2007-02-10 Thread Gabriel Genellina
En Sun, 11 Feb 2007 00:48:57 -0300, Jia Lu [EMAIL PROTECTED] escribió:

  I have a program that can telnet to a host.
  But I cannot understand from [for c in data] part, can anyone explain
 it to me?

data is the received string.
The for statement is used to iterate over a sequence; a string is  
considered a sequence of characters, so it iterates over all the  
characters in the string, one by one.

py data = Hello
py for c in data:
...   print c, ord(c)
...
H 72
e 101
l 108
l 108
o 111
py

-- 
Gabriel Genellina

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


Re: os.tmpfile() - permission denied (Win XP)

2007-02-10 Thread Gabriel Genellina
En Sun, 11 Feb 2007 01:57:52 -0300, John Machin [EMAIL PROTECTED]  
escribió:

 |  os.tmpfile()
 Traceback (most recent call last):
   File stdin, line 1, in module
 OSError: [Errno 13] Permission denied

 1. Before I start checking what permissions who has to do what to
 which, what directory is it likely to be trying to open the temp file
 in? C:\WINDOWS\TEMP?

You could analyze the source, but usually I find easier to use FILEMON:
http://www.sysinternals.com

-- 
Gabriel Genellina

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


Re: os.tmpfile() - permission denied (Win XP)

2007-02-10 Thread John Machin
On Feb 11, 4:15 pm, Gabriel Genellina [EMAIL PROTECTED] wrote:
 En Sun, 11 Feb 2007 01:57:52 -0300, John Machin [EMAIL PROTECTED]
 escribió:

  |  os.tmpfile()
  Traceback (most recent call last):
File stdin, line 1, in module
  OSError: [Errno 13] Permission denied

  1. Before I start checking what permissions who has to do what to
  which, what directory is it likely to be trying to open the temp file
  in? C:\WINDOWS\TEMP?

 You could analyze the source,

I have already followed the twisty little passages: os.tmpfile() is
really nt.tempfile(), but there is no Modules/ntmodule.c (Modules/
posixmodule.c does a Jekyll  Hyde trick). (nt|posix)module calls
tmpfile(), which is (as I mentioned) in the C stdio library. How can I
analyse the source of that? Have Microsoft had a rush of blood to the
head and gone open source overnight??

 but usually I find easier to use FILEMON:http://www.sysinternals.com

Thanks, I'll try that.

Cheers,
John

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


Re: pygame and python 2.5

2007-02-10 Thread [EMAIL PROTECTED]
On Feb 10, 11:03�pm, [EMAIL PROTECTED] wrote:
 � �  However, the difference between the open-source people and Microsoft
 � �  is the the open-source people aren't being paid by you for the use of
 � �  their product, so they're not obligated in any way to help you.

 � � mensanator This argument has become tiresome. The Python community
 � � mensanator wants Python to be a big fish in the big pond. That's why
 � � mensanator they make Windows binaries available.

 I suspect the main reason Windows binaries are produced is because a)
 Microsoft doesn't ship Python installed on Windows, and b) your garden
 variety Windows user doesn't have the tools necessary to build Python from
 source. �
 Not being a Windows user myself I don't understand all the ins and
 outs of VC6 v. VC7, legal or technical. �Is there nothing Microsoft could
 have done to make VC7 compatible with the existing VC6-based build
 procedure?

Ya got me, I'm not a softeware developer, I'm an
amateur math researcher. I don't know the ins and
outs either.


 Skip


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

Re: Retry:Question about optparse/OptionParser callback.

2007-02-10 Thread Steven Bethard
Steven W. Orr wrote:
 I'm writing a program that needs to process options. Due to the nature 
 of the program with its large number of commandline options, I would 
 like to write a callback to be set inside add_option.
 
 Something like this:
 
 parser.add_option(-b, action=callback, callback=optionhandlr, dest='b')

What do you want your callback to do? Actually, a better question is, 
what do you want to happen when the user specifies -b at the command line?

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


Re: pygame and python 2.5

2007-02-10 Thread Hendrik van Rooyen
Steve Holden [EMAIL PROTECTED]

 Hendrik van Rooyen wrote:
  [EMAIL PROTECTED] wrote:
  Ben Sizer [EMAIL PROTECTED] wrote:
  
  
  Ben Python extensions written in C require recompilation for each new
  Ben version of Python, due to Python limitations.
 
  Can you propose a means to eliminate this limitation?
 
  
  Yes.   - Instead of calling something, send it a message...
  
 I suppose you are proposing to use the ISO 1.333 generic 
 message-passing interface for this? The one that doesn't actually call a 
 function to pass a message?
 

Actually I am not aware that this ISO standard exists.

My feeling about ISO standards in general are such that 
I would rather have *anything* else than an ISO standard.
These feelings are mainly caused by the frustration of trying
to decipher standards written in standardese, liberally sprinkled
with non standard acronyms...

Its very interesting to learn that you can pass a message without
doing a call - when I next need to entertain a children's party as a
magician I will endeavour to incorporate it into my act.  Thanks 
for the tip.

But more seriously, the concept is that you should couple
as loosely as possible, to prevent exactly the kind of trouble
that this thread talks about.  Just as keyword parameters are
more robust than positional parameters, the concept of doing
something similar to putting a dict on a queue, is vastly more 
future-proof than hoping that your call will *get through*
when tomorrow's compiler buggers around with the calling 
convention.

One tends to forget that calling also builds messages on 
the stack.

When you boil it right down, all you need for a minimalistic
interface are four message types:

- get something's value
- set something to a value
- return the requested value
- do something  

This is not the most minimalistic interface, but its a nice 
compromise.

The advantages of such loose coupling are quite obvious when 
you think about them, as you don't care where the worker sits -
on the other side of the world over the internet, or in the same 
room in another box, or in the same box on another processor, 
or on the same processor in another process, or in the same 
process in another thread...

The problem with all this, of course, is the message passing 
mechanism, as it is not trivial to implement something that
will address all the cases. A layered approach (ISO ?  ; - )  )
could do it...

But Skip asked how to sort it, and this would be 
My Way.   (TM circa 1960 F Sinatra)

- Hendrik


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


Re: os.tmpfile() - permission denied (Win XP)

2007-02-10 Thread John Machin
On Feb 11, 4:33 pm, John Machin [EMAIL PROTECTED] wrote:
 On Feb 11, 4:15 pm, Gabriel Genellina [EMAIL PROTECTED] wrote:

  En Sun, 11 Feb 2007 01:57:52 -0300, John Machin [EMAIL PROTECTED]
  escribió:

   |  os.tmpfile()
   Traceback (most recent call last):
 File stdin, line 1, in module
   OSError: [Errno 13] Permission denied

   1. Before I start checking what permissions who has to do what to
   which, what directory is it likely to be trying to open the temp file
   in? C:\WINDOWS\TEMP?

  You could analyze the source,

 I have already followed the twisty little passages: os.tmpfile() is
 really nt.tempfile(), but there is no Modules/ntmodule.c (Modules/
 posixmodule.c does a Jekyll  Hyde trick). (nt|posix)module calls
 tmpfile(), which is (as I mentioned) in the C stdio library. How can I
 analyse the source of that? Have Microsoft had a rush of blood to the
 head and gone open source overnight??

  but usually I find easier to use FILEMON:http://www.sysinternals.com

 Thanks, I'll try that.

While Filemon is still alive, it's been superceded by Procmon, which
combines filemon + regmon + plus new goodies. I tried procmon.

And the result of an administrator user doing os.tmpfile():
281773  4:50:14.8607126 PM  python.exe  2716CreateFile  C:\t2ks 
SUCCESS
Access: Generic Read/Write, Delete, Disposition: Create, Options:
Synchronous IO Non-Alert, Non-Directory File, Delete On Close,
Attributes: N, ShareMode: Read, Write, Delete, AllocationSize:
3,184,748,654,057,488,384
[big snip]

*** AARRGGHH It's creating the file in the *ROOT* directory ***

A quick google for tmpfile root directory reveals that this is a
popular problem on Windows. See e.g. http://bugs.mysql.com/bug.php?
id=3998 which has several users corroborating the story, plus this
handy hint:

But MSDN says (ms-help://MS.MSDNQTR.2003APR.1033/vclib/html/
_crt_tmpfile.htm):
---
The tmpfile function creates a temporary file and returns a pointer to
that stream. The temporary file is created in the root directory. To
create a temporary file in a directory other than the root, use tmpnam
or tempnam in conjunction with fopen.


I wonder why my environment has entries for TMP and TEMP (both
pointing to the same path, and it sure ain't the root directory) --
must be one of those haha fooled you tricks :-(

Regards,
John

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


Stereo 3D photography capture stereoscopic still and motion images

2007-02-10 Thread icester

http://www.tyrell-innovations-usa.com/shack3d/productinfo/jpsBrown/jpsBrownInfo.htm


http://tyrell-innovations-usa.com/shack3d/








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


can't find a way to display and print pdf through python.

2007-02-10 Thread krishnakant Mane
hello all,
I am stuck with a strange requirement.
I need a library that can help me display a pdf file as a report and
also want a way to print the same pdf file in a platform independent
way.
if that's not possible then I at least need the code for useing some
library for connecting to acrobat reader and giving the print command
on windows and some thing similar on ubuntu linux.
the problem is that I want to display reports in my application.  the
user should be able to view the formatted report on screen and at his
choice click the print button on the screen to send it to the printer.
I have reportlab installed and that is sufficient to generate pdf reports.
but I still can't fine the way to display it directly and print it directly.
Please help me.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: can't find a way to display and print pdf through python.

2007-02-10 Thread Vishal Bhargava
Use Report Lab...
Cheers,
Vishal

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
krishnakant Mane
Sent: Saturday, February 10, 2007 10:46 PM
To: python-list@python.org
Subject: can't find a way to display and print pdf through python.

hello all,
I am stuck with a strange requirement.
I need a library that can help me display a pdf file as a report and
also want a way to print the same pdf file in a platform independent
way.
if that's not possible then I at least need the code for useing some
library for connecting to acrobat reader and giving the print command
on windows and some thing similar on ubuntu linux.
the problem is that I want to display reports in my application.  the
user should be able to view the formatted report on screen and at his
choice click the print button on the screen to send it to the printer.
I have reportlab installed and that is sufficient to generate pdf reports.
but I still can't fine the way to display it directly and print it directly.
Please help me.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list

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


Re: can't find a way to display and print pdf through python.

2007-02-10 Thread krishnakant Mane
On 11/02/07, Vishal Bhargava [EMAIL PROTECTED] wrote:
 Use Report Lab...
I mentioned in my first email that I am already using reportlab.
but I can only generate pdf out of that.
I want to display it on screen and I also will be giving a print
button which should do the printing job.
by the way I use wxpython for gui.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython libraries never detected

2007-02-10 Thread Steve Holden
hg wrote:
 hg wrote:
 
 [EMAIL PROTECTED] wrote:

 On Feb 10, 1:07 pm, hg [EMAIL PROTECTED] wrote:
 By default, you need to have wx installed in the python site-package
 path / under Mandriva, I have wx 2.8 installed
 here:  /usr/lib/python2.4/site-packages/wx-2.8-gtk2-ansi/

 hg
 Ah, now I see. But I have a new problem:

 ls /usr/lib/python2.4/site-packages | grep wx-2.8 returns wx-2.8-
 gtk2-unicode

 I copied wx-2.8-gtk2-unicode to /usr/lib/python2.5/site-packages/,
 which I assume the programs I am attempting to compile and run are
 using by default, but they still do not find the libraries. How can I
 tell where the programs are searching for the libraries?

 Thanks.
 If you're going to try the copy technique (never tried it) , you also need
 to copy wx.pth and wxversion.py.

 hg
 
 Oh, and remember that a 2.4.pyc will not run with 2.5 ... so I would also
 remove all .pyc that I might have copied.
 
In fact the interpreter will attempt to regenerate .pyc files if the 
current ones are from the wrong version, irrespective of file creation 
times.

This is a good reason why you shouldn't share pure Python libraries 
between different versions (which I have just realised that a couple of 
my projects are still doing, explaining some extended timings I'd been 
wondering about - great question!)

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Blog of Note:  http://holdenweb.blogspot.com
See you at PyCon? http://us.pycon.org/TX2007

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


Re: Regular Expressions

2007-02-10 Thread Steve Holden
Geoff Hill wrote:
 What's the way to go about learning Python's regular expressions? I feel 
 like such an idiot - being so strong in a programming language but knowing 
 nothing about RE. 
 
 
In fact that's a pretty smart stance. A quote attributed variously to 
Tim Peters and Jamie Zawinski says Some people, when confronted with a 
problem, think 'I know, I'll use regular expressions.' Now they have two 
problems.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Blog of Note:  http://holdenweb.blogspot.com
See you at PyCon? http://us.pycon.org/TX2007

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


RE: can't find a way to display and print pdf through python.

2007-02-10 Thread Vishal Bhargava
Are you trying to do real time or post real time. 
-Vishal

-Original Message-
From: krishnakant Mane [mailto:[EMAIL PROTECTED] 
Sent: Saturday, February 10, 2007 10:50 PM
To: Vishal Bhargava
Cc: python-list@python.org
Subject: Re: can't find a way to display and print pdf through python.

On 11/02/07, Vishal Bhargava [EMAIL PROTECTED] wrote:
 Use Report Lab...
I mentioned in my first email that I am already using reportlab.
but I can only generate pdf out of that.
I want to display it on screen and I also will be giving a print
button which should do the printing job.
by the way I use wxpython for gui.
Krishnakant.

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


Re: HTML Parsing

2007-02-10 Thread Ayaz Ahmed Khan
mtuller typed:

 I have also tried Beautiful Soup, but had trouble understanding the
 documentation

As Gabriel has suggested, spend a little more time going through the
documentation of BeautifulSoup. It is pretty easy to grasp.

I'll give you an example: I want to extract the text between the
following span tags in a large HTML source file.

span class=titleLinux Kernel Bluetooth CAPI Packet Remote Buffer Overflow 
Vulnerability/span

 import re
 from BeautifulSoup import BeautifulSoup
 from urllib2 import urlopen
 soup = BeautifulSoup(urlopen('http://www.someurl.tld/')) 
 title = soup.find(name='span', attrs={'class':'title'}, 
 text=re.compile(r'^Linux \w+'))
 title
u'Linux Kernel Bluetooth CAPI Packet Remote Buffer Overflow Vulnerability'

-- 
Ayaz Ahmed Khan

A witty saying proves nothing, but saying something pointless gets
people's attention.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygame and python 2.5

2007-02-10 Thread Steve Holden
Ben Sizer wrote:
 On Feb 10, 8:42 am, Steve Holden [EMAIL PROTECTED] wrote:
 Hendrik van Rooyen wrote:
 [EMAIL PROTECTED] wrote:
 Ben Sizer [EMAIL PROTECTED] wrote:
 Ben Python extensions written in C require recompilation for each new
 Ben version of Python, due to Python limitations.
 Can you propose a means to eliminate this limitation?
 Yes.   - Instead of calling something, send it a message...
 I suppose you are proposing to use the ISO 1.333 generic
 message-passing interface for this? The one that doesn't actually call a
 function to pass a message?
 
 I'm assuming you're being facetious here..?
 
You're right.

 Of course, functions get called at the ends of the message passing
 process, but those functions can stay the same across versions while
 the messages themselves change. The important part is reducing the
 binary interface between the two sides to a level where it's trivial
 to guarantee that part of the equation is safe.
 
 eg.
 Instead of having PySomeType_FromLong(long value) exposed to the API,
 you could have a PyAnyObject_FromLong(long value, char*
 object_type_name). That function can return NULL and set up an
 exception if it doesn't understand the object you asked for, so Python
 versions earlier than the one that implement the type you want will
 just raise an exception gracefully rather than not linking.
 
 The other issue comes with interfaces that are fragile by definition -
 eg. instead of returning a FILE* from Python to the extension,  return
 the file descriptor and create the FILE* on the extension side with
 fdopen.
 
I agree that the coupling is rather tight at the moment and could do 
with being loosened to the degree you suggest.

My previous post was a knee-jerk reaction to the suggestion that 
substituting one mechanism for another equivalent one would, by itself, 
solve anything.

I am staying away from the Py3.0 discussions at the moment - does 
anybody know whether this problem is being addresses there?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Blog of Note:  http://holdenweb.blogspot.com
See you at PyCon? http://us.pycon.org/TX2007

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


Re: can't find a way to display and print pdf through python.

2007-02-10 Thread krishnakant Mane
On 11/02/07, Vishal Bhargava [EMAIL PROTECTED] wrote:
 Are you trying to do real time or post real time.
 -Vishal

post real time.
I want to first display the report on screen by default and the user
at his choice will click the print button and the report will be
printed.
regards.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygame and python 2.5

2007-02-10 Thread Steve Holden
[EMAIL PROTECTED] wrote:
 On Feb 10, 4:07?pm, Ben Sizer [EMAIL PROTECTED] wrote:
 On Feb 10, 6:31 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 On Feb 9, 11:39?am, Ben Sizer [EMAIL PROTECTED] wrote:
 Hopefully in the future, some of those convoluted steps will be fixed,
 but that requires someone putting in the effort to do so. As is often
 the case with Python, and indeed many open source projects, the people
 who are knowledgeable enough to do such things usually don't need to
 do them, as their setup already works just fine.
 So you're saying the knowledgeable people's attitude
 is fuck everyone else as lomg as it's not MY problem?
 And you people complain about Microsoft.
 Am I one of those people? You don't exactly make it clear.
 
 I'm talking about the people who complain about Microsoft
 making the VC6 compiler no longer legally available and
 yet are so irresponsible that they use it for the latest
 release.
 
I think you'll find those two sets are disjoint.

 But yes, there is a lot of well, it works for me going around. If
 you do that long enough, people stop complaining, so people wrongly
 assume there's no longer a problem. This is partly why Python has
 various warts on Windows and why the standard libraries are oddly
 biased, why configuring Linux almost always ends up involving hand-
 editing a .conf file, why the leading cross-platform multimedia
 library SDL still doesn't do hardware graphics acceleration a decade
 after such hardware became mainstream, and so on.

 However, the difference between the open-source people and Microsoft
 is the the open-source people aren't being paid by you for the use of
 their product, so they're not obligated in any way to help you.
 
 This argument has become tiresome. The Python community
 wants Python to be a big fish in the big pond. That's why
 they make Windows binaries available.
 
? I would suggest rather that the Python community (by which you 
apparently mean the developers) hope that the fruits of their labours 
will be used by as wide a cross-section of computer users as possible.

The goals of open source projects are not those of commercial product 
developers: I and others wouldn't collectively put in thousands of 
unpaid hours a year to make a commercial product better and protect its 
intellectual property, for example.

 After all, they have already given freely and generously, and if they choose
 not to give more on top of that, it's really up to them.
 
 Right. Get people to commit and then abandon them. Nice.
 
Anyone who committed to Python did so without being battered by a 
multi-million dollar advertising campaign. The Python Software 
Foundation has only recently dipped its toes in the advocacy waters, 
with results that are still under evaluation. And the use of the 
Microsoft free VC6 SDK was never a part of the official means of 
producing Python or its extensions, it was a community-developed 
solution to the lack of availability of a free VS-compatible compilation 
system for extension modules.

I agree that there are frustrations involved with maintaining extension 
modules on the Windows platform without having a copy of Visual Studio 
(of the correct version) available. One of the reasons Python still uses 
an outdated version of VS is to avoid forcing people to upgrade. Any 
such decision will have fallout. An update is in the works for those 
using more recent releases, but that won't help users who don't have 
access to Visual Studio.

 Yes, it's
 occasionally very frustrating to the rest of us, but that's life.
 
 As the Kurds are well aware.
 
I really don't think you help your argument by trying to draw parallels 
between the problems of compiler non-availability and those of a 
population subject to random genocide. Try to keep things in 
perspective, please.

 The best I feel I can do is raise these things on occasion,
 on the off-chance that I manage to catch the attention of
 someone who is
 altruistic, knowledgeable, and who has some spare time on
 their hands!
 
 Someone who, say, solved the memory leak in the GMPY
 divm() function even though he had no way of compiling
 the source code?
 
 Just think of what such an altruistic, knowedgeable
 person could do if he could use the current VC compiler
 or some other legally available compiler.

Your efforts would probably be far better spent trying to build a 
back-end for mingw or some similar system into Python's development 
system, to allow Python for Windows to be built on a regular rather than 
a one-off basis using a completely open source tool chain.

The fact that the current maintainers of the Windows side of Python 
choose to use a commercial tool to help them isn't something I am going 
to try and second-guess. To do so would be to belittle efforts I would 
have no way of duplicating myself, and I have far too much respect for 
those efforts to do so.

There are published ways to build extension modules for Windows using 
mingw, by the way - have 

Re: can't find a way to display and print pdf through python.

2007-02-10 Thread Geoff Hill
Are you trying to:
a) Make the PDF file open in it's default application?
b) Create a PDF-reader in Python?

...because your question is somewhat unclear. Report Lab has no PDF viewer. 
You would need a PDF/PostScript parser to do that and that's more of a job 
than I think you're looking for. 


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


Re: pygame and python 2.5

2007-02-10 Thread Hendrik van Rooyen
Ben Sizer [EMAIL PROTECTED] wrote:


 On Feb 10, 8:42 am, Steve Holden [EMAIL PROTECTED] wrote:
  Hendrik van Rooyen wrote:
   [EMAIL PROTECTED] wrote:
   Ben Sizer [EMAIL PROTECTED] wrote:
 
   Ben Python extensions written in C require recompilation for each
new
   Ben version of Python, due to Python limitations.
 
   Can you propose a means to eliminate this limitation?
 
   Yes.   - Instead of calling something, send it a message...
 
  I suppose you are proposing to use the ISO 1.333 generic
  message-passing interface for this? The one that doesn't actually call a
  function to pass a message?

 I'm assuming you're being facetious here..?

Please see my reply to Steve - and Yes, I believe he was oulling the oiss...


 Of course, functions get called at the ends of the message passing
 process, but those functions can stay the same across versions while
 the messages themselves change. The important part is reducing the
 binary interface between the two sides to a level where it's trivial
 to guarantee that part of the equation is safe.

 eg.
 Instead of having PySomeType_FromLong(long value) exposed to the API,
 you could have a PyAnyObject_FromLong(long value, char*
 object_type_name). That function can return NULL and set up an
 exception if it doesn't understand the object you asked for, so Python
 versions earlier than the one that implement the type you want will
 just raise an exception gracefully rather than not linking.

 The other issue comes with interfaces that are fragile by definition -
 eg. instead of returning a FILE* from Python to the extension,  return
 the file descriptor and create the FILE* on the extension side with
 fdopen.

This sort of thing is exactly what is wrong with the whole concept of
an API...
Its very difficult, if not impossible, to guarantee that *my stuff* and
*your stuff* will work together over time.

Whereas if *my stuff* just publishes a message format, *anything* that
can make up the message can interact with it - but it requires *my stuff*
to be independently executable, and it needs a message passing
mechanism that will stand the test of time.

And it can create a whole new market of Mini Appliances each of
which has *your stuff* inside them...

- Hendrik


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


[ python-Feature Requests-1656675 ] Drop-Handler for Python files

2007-02-10 Thread SourceForge.net
Feature Requests item #1656675, was opened at 2007-02-10 12:36
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1656675group_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: Installation
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Marek Kubica (leonidasxiv)
Assigned to: Nobody/Anonymous (nobody)
Summary: Drop-Handler for Python files

Initial Comment:
Hi!

We had a dscussion about what happens when one drops a file on a python 
sourcecode-file in the python-forum [1]. It turned out, that nothing happens at 
all. So someone brought up a solution. It is not really a problem with Python 
but it would be nice to add this to the Windows Installer.

The proposed solution was to add the following to the registry (this is the 
format of the registry editor):

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Python.File\shellex\DropHandler]
@={86C86720-42A0-1069-A2E8-08002B30309D}

[HKEY_CLASSES_ROOT\Python.NoConFile\shellex\DropHandler]
@={86C86720-42A0-1069-A2E8-08002B30309D}

[HKEY_CLASSES_ROOT\Python.CompiledFile\shellex\DropHandler]
@={86C86720-42A0-1069-A2E8-08002B30309D}

That should be simple thing to do using the MSI-Installer.

[1] only in german, sorry: http://www.python-forum.de/topic-7493.html

--

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



[ python-Bugs-1653416 ] print f, Hello produces no error: normal?

2007-02-10 Thread SourceForge.net
Bugs item #1653416, was opened at 2007-02-06 17:23
Message generated for change (Comment added) made by eolebigot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1653416group_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: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: E.-O. Le Bigot (eolebigot)
Assigned to: Nobody/Anonymous (nobody)
Summary: print  f, Hello produces no error: normal?

Initial Comment:
When using
  print  f, Hello
on a file f opened for reading, no exception is raised.  Is this normal?

This situation has to be contrasted with
  f.write(Hello)
which raises an exception.

Details with Python 2.5 (r25:51908, Sep 24 206) on OS X 10.4.8 / darwin 8.8.0:

In [1]: f=open(start.01)
In [2]: f.write(Hello)
type 'exceptions.IOError': [Errno 9] Bad file descriptor
In [3]: print  f, Hello
In [4]: f.close()

NB: file f is not modified, despite the print statement yielding no error, 
above.

--

Comment By: E.-O. Le Bigot (eolebigot)
Date: 2007-02-10 12:49

Message:
Logged In: YES 
user_id=1440667
Originator: YES

Just for reference: with Fink Python 2.5 (r25:51908, Sep 24 2006) on OS X
10.4.8 / darwin 8.8.0 for Intel Macs, print f, 3 is also silently (and
incorrectly) accepted when f is only opened for reading.

--

Comment By: Martin v. Löwis (loewis)
Date: 2007-02-10 00:14

Message:
Logged In: YES 
user_id=21627
Originator: NO

There seem to be multiple problems here. AFAICT,

print f, 3

fails on both Linux and OSX. This is because this uses fprintf to put out
the number, which, in turn, returns -1. This result is ignored; instead
Python expects ferror() to be set. However, ferror doesn't get set.

For printing strings, fwrite is used. On both Linux and OSX, fwrite will
return 0. On Linux, in addition, ferror gets set; on OSX, it doesn't.

Reading C99, I can't figure out which of these systems is behaving
correctly in what cases. The definition of ferror is that it returns the
error indicator of the stream, and only fseek, fputc (+putc), and fflush
are explicitly documented to set the error indicator. However, the error
indicator is also documented to be set that it records whether a 
read/write error  has  occurred, and write is documented to return a
number smaller than the requested only if an error occurred. Likewise,
fprintf is document to return an negative value if an  output  or 
encoding error occurred.

Putting these all together, ISTM that both Linux and OSX implement fprintf
incorrectly. To work around, Python could check the result of fprintf and
fwrite in all places; this might become a large change.

--

Comment By: Skip Montanaro (montanaro)
Date: 2007-02-06 19:49

Message:
Logged In: YES 
user_id=44345
Originator: NO

I verified this behavior on my Mac with /usr/bin/python, Python 2.5 and
Python 2.6a0, both built from SVN.

Skip


--

Comment By: E.-O. Le Bigot (eolebigot)
Date: 2007-02-06 18:45

Message:
Logged In: YES 
user_id=1440667
Originator: YES

Interesting point, about Linux.   The incorrect behavior is even seen in
the  default python 2.3 that ships with Mac OS X!


--

Comment By: Georg Brandl (gbrandl)
Date: 2007-02-06 18:31

Message:
Logged In: YES 
user_id=849994
Originator: NO

If this happens, it's a bug. Though it doesn't seem to occur under Linux
here.

--

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



[ python-Feature Requests-1656675 ] Drop-Handler for Python files

2007-02-10 Thread SourceForge.net
Feature Requests item #1656675, was opened at 2007-02-10 11:36
Message generated for change (Settings changed) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1656675group_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: Installation
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Marek Kubica (leonidasxiv)
Assigned to: Martin v. Löwis (loewis)
Summary: Drop-Handler for Python files

Initial Comment:
Hi!

We had a dscussion about what happens when one drops a file on a python 
sourcecode-file in the python-forum [1]. It turned out, that nothing happens at 
all. So someone brought up a solution. It is not really a problem with Python 
but it would be nice to add this to the Windows Installer.

The proposed solution was to add the following to the registry (this is the 
format of the registry editor):

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Python.File\shellex\DropHandler]
@={86C86720-42A0-1069-A2E8-08002B30309D}

[HKEY_CLASSES_ROOT\Python.NoConFile\shellex\DropHandler]
@={86C86720-42A0-1069-A2E8-08002B30309D}

[HKEY_CLASSES_ROOT\Python.CompiledFile\shellex\DropHandler]
@={86C86720-42A0-1069-A2E8-08002B30309D}

That should be simple thing to do using the MSI-Installer.

[1] only in german, sorry: http://www.python-forum.de/topic-7493.html

--

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



[ python-Bugs-1656559 ] I think, I have found this bug on time.mktime()

2007-02-10 Thread SourceForge.net
Bugs item #1656559, was opened at 2007-02-10 03:41
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1656559group_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: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Sérgio Monteiro Basto (sergiomb)
Assigned to: Nobody/Anonymous (nobody)
Summary: I think, I have found this bug on time.mktime()

Initial Comment:
well, I think, I have found this bug on time.mktime() for dates less
than 1976-09-26

when I do stringtotime of 1976-09-25 

print timeint %d % time.mktime(__extract_date(m) + __extract_time(m) + (0, 0, 
0)) 

extract date = 1976 9 25
extract time = 0 0 0
timeint 212454000
and 
timetostring(212454000) = 1976-09-24T23:00:00Z !? 

To be honest the date that kept me the action was the 1-1-1970 that
appears 31-12-1969. After timetostring(stringtotime(date)))

I made the test and time.mktime got a bug when date is less than
1976-09-26 
see:
for 1976-09-27T00:00:00Z time.mktime gives 212630400
for 1976-09-26T00:00:00Z time.mktime gives 212544000
for 1976-09-25T00:00:00Z time.mktime gives 212454000

212630400 - 212544000 = 86400 (seconds) , one day correct !
but
212544000 - 212454000 = 9 (seconds), one day more 3600 (seconds),
more one hour ?!? 

--
Sérgio M. B. 



--

Comment By: Georg Brandl (gbrandl)
Date: 2007-02-10 15:06

Message:
Logged In: YES 
user_id=849994
Originator: NO

This appears to be a timezone/DST issue:
on Sept. 26, 1976 Daylight Saving Time ended at least in the European
Union.

--

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



[ python-Feature Requests-1654367 ] [PATCH] Debuggers need a way to change the locals of a frame

2007-02-10 Thread SourceForge.net
Feature Requests item #1654367, was opened at 2007-02-07 17:12
Message generated for change (Comment added) made by arigo
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1654367group_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: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Fabio Zadrozny (fabioz)
Assigned to: Nobody/Anonymous (nobody)
Summary: [PATCH] Debuggers need a way to change the locals of a frame

Initial Comment:
Debuggers need a way to change the local variables in a given frame... 
currently, this works only if this change is done in the topmost frame (and 
under certain circumstances), but it should work for any frame.

Initial discussion at:
http://mail.python.org/pipermail/python-dev/2007-February/070884.html

Apparently, the problem is the order in which PyFrame_LocalsToFast / 
PyFrame_FastToLocals is called.

The proposed solution to this is having a savelocals() method in the frame 
object and have it reflect the changes in its returned dict into its locals. It 
will simply enable users to call PyFrame_LocalsToFast externally after a 
change, to be sure that it will not be changed (and it must be done before 
another call to PyFrame_LocalsToFast -- which I don't see as a large problem, 
because it is of restrict use -- mainly for debuggers).


- frameobject.c Patch part 1: -

static PyObject *
PyFrame_SaveLocals(PyFrameObject *f)
{
PyFrame_LocalsToFast(f, 0);
Py_INCREF(Py_None);
return Py_None;
}

static PyMethodDef frame_methodlist[] = {
{savelocals, (PyCFunction)PyFrame_SaveLocals, METH_NOARGS,
 After a change in f_locals, this method should be called to save the 
changes internally.
},
{NULL}  /* Sentinel */
};


-- frameobject.c Patch part 2: ---
Add to PyTypeObject PyFrame_Type:

frame_methodlist,/* tp_methods */

-- end patch -

I'm sorry that this is not in an actual patch format... but as I didn't get it 
from the cvs, it is easier for me to explain it (as it is a rather small patch).

Attached is a test-case for this patch.

Thanks, 

Fabio

--

Comment By: Armin Rigo (arigo)
Date: 2007-02-10 20:16

Message:
Logged In: YES 
user_id=4771
Originator: NO

A point of detail probably, but I suppose that instead of introducing a
new method on frame objects, we could allow f_locals to be a writeable
attribute.  Setting it to a dictionary would update the value of the local
variables.  It's a bit of a hack, but so is the need for an explicit
savelocals() method.

A cleaner solution is to have f_locals return a dict-like object instead
of a real dict when appropriate, but it takes more efforts to implement.

--

Comment By: Martin v. Löwis (loewis)
Date: 2007-02-08 08:38

Message:
Logged In: YES 
user_id=21627
Originator: NO

Why don't you set the clear parameter to 1?

Please do submit a patch, you can use 'diff -ur' to create a recursive
unified diff between source trees. Please also try to come up with a patch
to the documentation.

--

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



[ python-Bugs-1657034 ] 'Ok' key in options dialog does nothing

2007-02-10 Thread SourceForge.net
Bugs item #1657034, was opened at 2007-02-11 01:35
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1657034group_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: IDLE
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: torhu (torhu)
Assigned to: Nobody/Anonymous (nobody)
Summary: 'Ok' key in options dialog does nothing

Initial Comment:
IDLE 1.2, winxp sp2 US.

I get the same results with idlelib from svn rev. 53721.


Steps to reproduce:
1. Open Options - Configure IDLE...
2. Click on the Ok button.
3. Nothing happens, you have to click Cancel to close the options window.


Here's a way that crashes IDLE on my machine:
1. Open Options - Configure IDLE...
2. Set Indentation width to 8 (was 4 by default).
3. Click on Apply.
4. Click on Ok (nothing happens).
5. Click on Cancel - IDLE exits.


Workaround:
Replace the Python25/Lib/idlelib directory with the one that comes with python 
2.4.3.

--

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



[ python-Bugs-1656581 ] tarfile.TarFile fileobject use needs clarification

2007-02-10 Thread SourceForge.net
Bugs item #1656581, was opened at 2007-02-10 00:45
Message generated for change (Comment added) made by herrwitten
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1656581group_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: Documentation
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Witten (herrwitten)
Assigned to: Lars Gustäbel (gustaebel)
Summary: tarfile.TarFile fileobject use needs clarification

Initial Comment:
The constructor of a TarFile object expects an existing file object to have its 
file position at 0. This is not documented.

--

Comment By: Witten (herrwitten)
Date: 2007-02-11 00:35

Message:
Logged In: YES 
user_id=1595909
Originator: YES

I suppose I could make this clearer:

The user needs to know that the file object will be used from the current
file position.

--

Comment By: Witten (herrwitten)
Date: 2007-02-10 00:47

Message:
Logged In: YES 
user_id=1595909
Originator: YES

A clarification: When an existing file object is used to create a TarFile
object, the TarFile object expects the existing file object to have its
file position at 0.

--

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



<    1   2