Re: String Identity Test

2005-11-01 Thread Fredrik Lundh
Thomas Moore wrote: > I am confused at string identity test: > > Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on > win32 > Type "help", "copyright", "credits" or "license" for more information. a="test" b="test" a is b > True > > About identity, I think

Re: Scanning a file

2005-11-01 Thread Fredrik Lundh
Alex Martelli wrote: >> As far as I know, Python simply relies on the opreating system to close >> files left open at the end of the program. > > Nope, see > leobject.c?rev=2.164.2.3&view=markup> that's slightly misleading

Re: hello, I want to change n bytes of a binary file

2005-11-01 Thread Fredrik Lundh
"could ildg" wrote: > I want to encrypt a very large birany file, > but if to change the whole file, it will take very long time, > so I just want to change n(n is an int) bytes of the file. > but when I turned to the file I/O of python, I found that file object can > only read and write strings,

Re: hello, I want to change n bytes of a binary file

2005-11-01 Thread Fredrik Lundh
"could ildg" wrote: > > so how can I do the binary stuff? > > 8-bit strings contain bytes. > > > I want a encrypt function like below: > > def encrypt(filename,n): > > f = open(filename,"rb+") > > > a=f.read(n) > > b = encrypt(a) Thank you~~,but where is the encrypt defined? oh, I though

Re: Python's website does a great disservice to the language

2005-11-01 Thread Fredrik Lundh
"CppNewB" wrote: > I was trying to advocate using Python for an upcoming prototype, so my boss > went out to take a look at the documentation and try and get a feel for what > the language is all about. > > First comment; "I hope the language is designed better than the site." so your boss is a t

Re: Python's website does a great disservice to the language

2005-11-01 Thread Fredrik Lundh
message = message.replace("you're", "your") -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's website does a great disservice to the language

2005-11-01 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > So the first thing you do when you go to a web page is to google if > they are going to redesign it? the first thing he did was to go to the page, the next thing he did was to post a "can we round up a couple of designers?" message with an in- flammatory subject line.

Re: If Statement Error (Tic Tac Toe)

2005-11-02 Thread Fredrik Lundh
<[EMAIL PROTECTED]> wrote: > The only problem I have is whenever player two goes, it says the cell > is filled. But the code: > > if gameboard[cell] not in 'OX': >gameboard[cell] = 'X' >else: >print "This cell is already filled." >turnnu

Re: Python's website does a great disservice to the language

2005-11-02 Thread Fredrik Lundh
"CppNewB" wrote: > But the logos look like they were done in Paint that's probably why the designers won a prestigious design award for their: "...innovative letter designs and typographic experiments, which are testimony to their unconventional thinking about, and use of, existing s

Re: how to check for unix password

2005-11-02 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > i created a login page that authenticate the user and his/her password > to the unix ssystem. what modules can i used to compare the unix > password with what the user typed in the cgi form? the password is > encrypted (shadowed) so i need to decrypt it first before comp

Re: Xah's edu corner: the Journey of Foreign Characters thru Internet

2005-11-02 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > And if anyone wants to take the responsibiblity to warn the general > public that it is troll so innocent readers may not be tempted into > one, at least do it privately huh? -- http://mail.python.org/mailman/listinfo/python-list

Re: Subprocess.Popen - passing args help

2005-11-02 Thread Fredrik Lundh
"Ernesto" wrote: > A nice person from another thread helped me... > > a = 'disable "@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&' > print a > disable "@USB\VID_0403&PID_6010&MI_00&15E4F68&1& > > \7 is the ASCII bell so your args may be different from what you think. > > > I thought the quote

Re: where to download md5.py?

2005-11-02 Thread Fredrik Lundh
"Bell, Kevin" wrote: > I've been looking around, but haven't found a place to download the > md5.py module. I need it to run the dupinator.py md5 is a standard Python module (written in C). it's been in Python since the early ages, so if you don't have it, your install is most likely broken (p

Re: Xah's edu corner: the Journey of Foreign Characters thru Internet

2005-11-02 Thread Fredrik Lundh
Jarek Zgoda wrote: >>>And if anyone wants to take the responsibiblity to warn the general >>>public that it is troll so innocent readers may not be tempted into >>>one, at least do it privately >> >> huh? > > Don't fed the troll, don't give him any public audience. Easy. by sending private mail t

Re: is open(...).read() a resource leak?

2005-11-02 Thread Fredrik Lundh
Benjamin Rutt wrote: > If I did the following in an infinite loop, would the host system/user > account soon run out of file descriptors? (I'm thinking no, since I'd > imagine that a file object has a __del__-like method that will call > close() automatically since it goes out of scope): > >o

Re: reading internet data to generate random numbers.

2005-11-02 Thread Fredrik Lundh
Levi Campbell wrote: > Hi, I'm working on a random number generator using the internet as a > way to gather entropy, I have two questions. > > 1. is there a way to capture the internet stream? what's an internet stream? -- http://mail.python.org/mailman/listinfo/python-list

Re: where to download md5.py?

2005-11-02 Thread Fredrik Lundh
"Bell, Kevin" wrote: > I don't have sha either, but my system administrators don't know a thing > about python. How would they block it? That is the dupinator that I'm > talking about. Where would md5 and sha be if they were there? > C:\Python24\Lib? if you're using 2.4 on Windows, they're inc

Re: Filepath string manipulation help

2005-11-02 Thread Fredrik Lundh
"mjakowlew"wrote: > filepath='c:\documents\web\zope\file.ext' > > I need to extract everthing after the last '\' and save it. that string doesn't contain what you think it does: >>> filepath='c:\documents\web\zope\file.ext' >>> filepath 'c:\\documents\\web\\zope\x0cile.ext' >>> print filepath c:

Re: reading internet data to generate random numbers.

2005-11-02 Thread Fredrik Lundh
Peter Hansen wrote: >> Hi, I'm working on a random number generator using the internet as a >> way to gather entropy, I have two questions. >> >> 1. is there a way to capture the internet stream? > > What specifically do you mean by the term "internet stream" here? > Generally speaking, the intern

Re: Hexadecimal Conversion in Python

2005-11-02 Thread Fredrik Lundh
"DaBeef" wrote:/ > it is returning data such as 0x04. I am new to python so this is a > pain for me, learning to do this in a language whose llibrary is > somewhat limited. you make no sense at all. what are you receiving data from? how are you receiving it? what library are you using? what'

Re: how can I run python interactively?

2005-11-02 Thread Fredrik Lundh
"questions?" wrote: > I need to stop the program in the middle and pause there. > > Are there anyway I can stop the program in the middle and have > something like: > > please press y to continue. portable: raw_input("please press return to continue.") to get a single character, you

Re: Nested List Question

2005-11-02 Thread Fredrik Lundh
"Newsfeeds" <[EMAIL PROTECTED]> wrote: > Could anyone tell me why this code produces the output it does? http://www.python.org/doc/faq/programming.html#how-do-i-create-a-multidimensional-list has the full story. -- http://mail.python.org/mailman/listinfo/python-list

Re: when and how do you use Self?

2005-11-03 Thread Fredrik Lundh
"Tieche Bruce A MSgt USMTM/AFD" <[EMAIL PROTECTED]> wrote: > Could someone explain (in English) how and when to use self? > > I have been reading, and haven't found a good example/explanation consider a class C: >>> class C: ... def method(self): ... print self ...

Re: typo in the documentation or am I stupid?

2005-11-03 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote_ > In the embedding Python manual at Python.org an example is presented > that uses the function: > PyDict_GetAttrString. Is it possible that this is a typo? according to this checkin message ("fix stupid typo"), the answer is yes: http://mail.python.org/pipermail/pyt

Re: strtok equvialent ?

2005-11-03 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > are there a strtok equivalent in python ? str.split() only takes single > seperator. use a regular expression split with a character group: >>> s = "breakfast=spam+egg-bacon" >>> import re >>> re.split("[-+=]", s) ['breakfast', 'spam', 'egg', 'bacon']

Re: random number generator

2005-11-03 Thread Fredrik Lundh
> How to generate a random number in Python. Is there any build in > function I can call? >>> import random >>> help(random) also see: http://docs.python.org/lib/module-random.html -- http://mail.python.org/mailman/listinfo/python-list

Re: ExpatError attributes

2005-11-04 Thread Fredrik Lundh
Daniel Nogradi wrote: > According to the documentation the xml.parsers.expat module provides > the exception ExpatError and this exception has 3 attributes, lineno, offset > and code. I would like to use lineno, but can't. > try: > minidom.parse("my.xml") > except ExpatError: > print 'The

Re: exec behaviour

2005-11-04 Thread Fredrik Lundh
N. Pourcelot wrote: > I can't understand some specific behaviour of the exec statment. > > For example, say that I create such a class A : > > class A: > def __init__(self): > self.n = 3 > self.m = None > def h(self, ini): > n = self.n > m = self.m >

Re: re sub help

2005-11-05 Thread Fredrik Lundh
<[EMAIL PROTECTED]> wrote: > i am still interested about using re, i find it useful. am still > learning it's uses. > so i did something like this for a start, trying to get everything in > between [startdelim] and [enddelim] > > a = > "this\nis\na\nsentence[startdelim]this\nis\nanother[enddelim]t

Instead of obsessing over the library *reference*, why not use other documentation?

2005-11-06 Thread Fredrik Lundh
Charlton Wilbur wrote: > This is one of the places where Apple's Cocoa documentation shines: > there are frequently snippets of code accompanying more complicated > methods, which is nice, but there are a couple dozen small sample > programs that demonstrate how to use particular aspects of the >

finding and accessing multiple documentation sources

2005-11-06 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > This actually brings us back to the jest of F. previous post, that > documentation is question of multiple source reference, and yes that > you have to work the field (Google search, newgroups, cookbooks, > source-code, et al) a little bit to get some information. while

Re: Can't instantiate class

2005-11-06 Thread Fredrik Lundh
David Mitchell wrote: > Here is a very basic question, but it is frustrating me to no end > nonetheless. > > I have one file called addLink.py. In a method in this file I am trying > to instantiate a class and call a method from that class. Here is the code: > > def getCategories(): > # instantiat

Re: Clearing output screen

2005-11-06 Thread Fredrik Lundh
Ivan Shevanski wrote > I know there is a way to do this, but google doesn't seem to want to find it > =) There is a command to clear the output screen right? no, because "output screen" isn't a well-defined concept on modern operating systems. the following works in many cases: import os

Re: Can't instantiate class

2005-11-06 Thread Fredrik Lundh
David Mitchell wrote: > Ok, so If use your first suggestion (db = DataUtil.DataUtil() > ), I get this error: > > AttributeError: 'module' object has no attribute 'DataUtil' > > If I try importing the class directly (from DataUtil import DataUtil), > I get this error: > > ImportError: cannot import

Re: Validate string as UTF-8?

2005-11-06 Thread Fredrik Lundh
Tony Nelson wrote: > I'd like to have a fast way to validate large amounts of string data as > being UTF-8. define "validate". > I don't see a fast way to do it in Python, though: > > unicode(s,'utf-8').encode('utf-8) if "validate" means "make sure the byte stream doesn't use invalid sequen

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' inposition 99: ordinal not in range(128)

2005-11-06 Thread Fredrik Lundh
Francach wrote: > I don't know what I'm doing wrong here. > I''m using Python 2.4 and py2exe. I get he following error: > > Traceback (most recent call last): > File "notegui.pyc", line 34, in OnClose > File "brain.pyc", line 61, in setNote > File "points.pyc", line 151, in setNote > File

Re: "how to think like a computer scientist"

2005-11-06 Thread Fredrik Lundh
"john boy" wrote: > I am using the book "how to think like a computer scientist" and > am finding the examples are not working with Python 2.4.2...I have > typed them exactly as they appear in the textcan someone > relate to this?...is this typical b/c 2.4.2 is a newer version? no. did you r

Re: Perl XML::Simple and Data::Dumper - exists in Python?

2005-11-06 Thread Fredrik Lundh
Miguel Manso wrote: > Can you point me out to Python solutions for: > > 1) Perl's Data::Dumper > > It dumps any perl variable to the stdout in a "readable" way. >>> import pprint >>> help(pprint) > 2) Perl's XML::Simple > > It maps a XML file into a Perl data structure. some alternatives:

Re: pls help me with strange result

2005-11-07 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > db = Sybase.connect(DSN) > ... > def x_dml(SQL,conn): > ''' Connects to database specified, exec the SQL and returns > value''' > try: > c = conn.cursor() > try: > c.execute(SQL) >

Re: can i tar and untar using python

2005-11-07 Thread Fredrik Lundh
"sumi" <[EMAIL PROTECTED]> wrote: > can i tar and untar using python http://docs.python.org/lib/module-tarfile.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Sending email in utf-8?

2005-11-07 Thread Fredrik Lundh
"morphex" <[EMAIL PROTECTED]> wrote: > I have an email that's in the utf-8 encoding, and I'm getting this > error message when I try to send it using smtplib: > >* Module smtplib, line 688, in sendmail >* Module smtplib, line 485, in data >* Module smtplib, line 312, in send >* Mod

Re: RAW_INPUT

2005-11-07 Thread Fredrik Lundh
"A D" <[EMAIL PROTECTED]> wrote: >> print "You may pass,", s > > at this print line you need to do > print "you may pass, %s" % s > > this will allow you to enter the string s into the output sentence where did you buy your python license ? >>> s = "josh" >>> print "hello,", s hello,

Re: RAW_INPUT

2005-11-07 Thread Fredrik Lundh
"john boy" <[EMAIL PROTECTED]> : >I am having trouble with the following example used in a tutorial: > > print "Halt !" > s = raw_input ("Who Goes there? ") > print "You may pass,", s > > I run this and get the following: > Halt! > Who Goes there? > > --thats itif I hit enter again "You may pa

Re: when and how do you use Self?

2005-11-07 Thread Fredrik Lundh
"Tieche Bruce A MSgt USMTM/AFD" <[EMAIL PROTECTED]> wrote: > Well, thanx for all the ... useful information. > > I thought that I would try, but this has turned out to be a waist of my time. did you perhaps miss that at least three people wrote proper replies to your post? http://article.gm

Re: Returning a value from a Tk dialog

2005-11-07 Thread Fredrik Lundh
Gordon Airporte wrote: > The dialogs in tkColorChooser, tkFileDialog, etc. return useful values > from their creation somehow, so I can do stuff like this: > > filename = tkFileDialog.askopenfilename( master=self ) > > I would like to make a Yes/No/Cancel dialog that can be used the same > way (re

Re: how to stop a loop with ESC key? [newbie]

2005-11-08 Thread Fredrik Lundh
"mo" <[EMAIL PROTECTED]> wrote: > Can somebody explain how to stop a WHILE loop in running program by pressing > ESC key? depends on the platform. on windows, you can use the mscvrt module: import msvcrt while ...: ... if msvcrt.kbhit() and msvcrt.getch() == chr(27):

Re: socket receive file does not match sent file

2005-11-08 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > while True: >data = f.read(8192) >if not data: break >else: >s.send(data) > What is the cause of the problem, can anyone tell me? using sendall instead of send should fix this. see the library reference for details: send( s

Re: image

2005-11-08 Thread Fredrik Lundh
Shi Mu wrote: > why the following code report the error: > Traceback (most recent call last): > File > "C:\Python23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", > line 310, in RunScript >exec codeObject in __main__.__dict__ > File "C:\Python23\Examples\AppB\text.py", line 24

Re: image

2005-11-08 Thread Fredrik Lundh
> > File "C:\Python23\lib\lib-tk\Tkinter.py", line 2882, in image_create > >return self.tk.call( > > TclError: image "pyimage4" doesn't exist > > works for me, when running it from a stock CPython interpreter. > > have you tried running the script outside the pywin environment? btw, the error

Re: how to stop a loop with ESC key? [newbie]

2005-11-08 Thread Fredrik Lundh
"mo" <[EMAIL PROTECTED]> wrote: > I tryed your example: > > import msvcrt > while 1: >print '.' >if msvcrt.kbhit() and msvcrt.getch() == chr(27): > break > > but it doesn't work. It is running (Win2000), there is no messages about > errors but there is no effect when pressing ESC k

Re: Sorting Documentation

2005-11-08 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote_ >I want to read a little bit about sorting in Python (sorted() and > method sort()). But I can't seem to find anything in the documentation > at the homepage? sorted() is a function that works on arbitrary sequences, and is described in the "built-in functions" chapter:

Re: Writing Win32 shell extensions in python?

2005-11-08 Thread Fredrik Lundh
"Thomas W" <[EMAIL PROTECTED]> wrote: > Well, is it possible to write Win32 shell extension in python? I want > to create a virtual folder ( like gmailfs ) to serve files from a > http-server ( and no, I cannot use webdav ) so that users can access > them like normal files in Windows Explorer. > >

Re: Sending email in utf-8?

2005-11-08 Thread Fredrik Lundh
"morphex" <[EMAIL PROTECTED]> wrote: > """ > Date: Mon, 7 Nov 2005 11:38:29 -0700 (MST) > Message-Id: <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED], [EMAIL PROTECTED] > From: [EMAIL PROTECTED] > Subject: Order confirmation > Content-Type: text/plain; charset="utf-8" > X-Bogosity: No, tests=bogofilt

Re: Cursor Position.

2005-11-08 Thread Fredrik Lundh
"Samantha" <[EMAIL PROTECTED]> wrote: > Looking at the goto(xy) thread. > Is there a way to get the X,Y position from a cursor click and then use the > position to apply something like a water mark on an image at that position? All GUI toolkits can handle the "click here" part. Which one are you

Re: not able to HTTPS page from python

2005-11-09 Thread Fredrik Lundh
<[EMAIL PROTECTED]> wrote: > AM NOT GETTING ANY ERRORS EITHER BUT ITS NOT READING THE LINKS, THAT > ARE PRESENT IN THE GIVEN HTTPS PAGE HAVE YOU TRIED ADDING A PRINT STATEMENT TO THE FEED LOOP SO YOU CAN SEE WHAT YOU'RE GETTING BACK FROM THE SERVER ? -- http://mail.python.org/mailman/listin

Re: append to non-existing list

2005-11-09 Thread Fredrik Lundh
Yves Glodt wrote: > if I do this: > > for row in sqlsth: > pkcolumns.append(row[0].strip()) > etc > > without a prior: > > pkcolumns = []; > > I get this error on first iteration: > UnboundLocalError: local variable 'pkcolums' referenced before assignment > > I guess that's normal

Re: append to non-existing list

2005-11-09 Thread Fredrik Lundh
Yves Glodt wrote: > I am fairly new to python (and I like it more and more), but I can not > answer this question... As I said, where I come from it is possible, and > how they do it is explained a little here: > http://lu.php.net/manual/en/language.types.type-juggling.php but that page doesn't d

Re: PIL-> Tkinter

2005-11-09 Thread Fredrik Lundh
"Tuvas" <[EMAIL PROTECTED]> wrote > Is there a way to put an image loaded from PIL into a TKinter GUI? > Without converting the image to a .bmp, and using a canvas? If that's > the only way it'll work, I'll take it, but... It would be nice > otherwise... hmm. is google down today? here's a rand

Re: PyFLTK - an underrated gem for GUI projects

2005-11-09 Thread Fredrik Lundh
Claudio Grondi wrote: > Running some of the test examples > (e.g. C:\Python24\pyfltk\test\doublebuffer.py) > I am getting an error I have never seen before: > > == > TitleOfMessageBox: > Microsoft Visual C++ Runtime Library > > TheMessag

Re: append to non-existing list

2005-11-09 Thread Fredrik Lundh
Mike Meyer wrote: > Float doesn't handle implicit conversion to anything but but builtin types. > In particular, it doesn't check to see if the object beinng added has a > __float__ method, and invoke that to do the conversion if it does. that's because __float__ is there to let you control what

Re: Python obfuscation

2005-11-09 Thread Fredrik Lundh
"petantik" <[EMAIL PROTECTED]> wrote: > Are there any commercial, or otherwise obfuscators for python source > code or byte code and what are their relative advantages or > disadvantages. I wonder because there are some byte code protection > available for java and .NET, although from what i've r

Re: PYTHON LOOSING FOR JAVA???????

2005-11-09 Thread Fredrik Lundh
James Colannino wrote >>+1 QOTW > > My ignorance shows here. What does that mean? :-P +1 => http://www.python.org/peps/pep-0010.html QOTW => Quote Of The Week -- http://mail.python.org/mailman/listinfo/python-list

Re: xml.minidom and user defined entities

2005-11-09 Thread Fredrik Lundh
Nick Craig-Wood wrote: > I'm using xml.minidom to parse some of our XML files. Some of these > have entities like "°" in which aren't understood by xml.minidom. ° is not a standard entity in XML (see below). > These give this error. > > xml.parsers.expat.ExpatError: undefined entity: line 12,

Re: Floating numbers and str

2005-11-09 Thread Fredrik Lundh
"Tuvas" <[EMAIL PROTECTED]> wrote: >I would like to limit a floating variable to 4 signifigant digits, when > running thorugh a str command. Ei, > > x=.13241414515 > y=str(x)+" something here" > > But somehow limiting that to 4 sign. digits. I know that if you use the > print statement, you can do

Re: How to set program name in Python? ($0 in Perl)

2005-11-09 Thread Fredrik Lundh
Steve Holden wrote: > > Is there a way to set the program name in Python, similar to $0 in > > Perl? > > > >>From `man perlvar`: > > > > $0 Contains the name of the program being executed. On some oper- > >ating systems assigning to "$0" modifies the argument > > area that >

Re: How to set program name in Python? ($0 in Perl)

2005-11-10 Thread Fredrik Lundh
Swaroop C H wrote: > Thanks Fredrik for the info. > > It was not a must-have, I was just curious if it was possible. it should be noted that some systems have a setproctitle() function, but the design of that API comes with its own can of quality worms: http://www.cert.org/advisories/CA-200

Re: append to non-existing list

2005-11-10 Thread Fredrik Lundh
Yves Glodt wrote: > Is there a possibility to bring together apache and python in a way that > I can embed python into html? http://www.onlamp.com/pub/a/python/2004/02/26/python_server_pages.html http://www.modpython.org/live/mod_python-3.2.2b/doc-html/pyapi-psp.html#pyapi-psp -- http://ma

Re: Python as a HTTP Client

2005-11-10 Thread Fredrik Lundh
"[EMAIL PROTECTED]" wrote: >I am writing a program that has to do some lightweight HTTP > communication with a webserver on the internet. I haven't checked, but > I'm sure I could do something lowlevel like opening a socket myself and > then send/receive everything myself on this (how do I do that

Re: A Tcl/Tk programmer learns Python--any advice?

2005-11-10 Thread Fredrik Lundh
Svenn Are Bjerkem wrote: > (and python can not do "set result [exec someprog << $input]" as far as > I know) execute a pro import subprocess -- http://mail.python.org/mailman/listinfo/python-list

Re: A Tcl/Tk programmer learns Python--any advice?

2005-11-10 Thread Fredrik Lundh
oops. > (and python can not do "set result [exec someprog << $input]" as far as > I know) execute a script inside a list comprehension and shift it to the left by a built-in function ? I suspect you want: import subprocess -- http://mail.python.org/mailman/listinfo/python-list

Re: Newb ??

2005-11-10 Thread Fredrik Lundh
Norman Silverstone wrote: > > Heh, you will find that Python is practically executable pseudo-code! > > > > Untested: > > > > > > def guess_number(): > > # please don't cheat the poor computer... > > print "Guess a number." > > lo = 0 > > hi = 100 > > while True: > > gue

Re: Newb ??

2005-11-10 Thread Fredrik Lundh
Norman Silverstone wrote: > > Heh, you will find that Python is practically executable pseudo-code! > > > > Untested: > > > > > > def guess_number(): > > # please don't cheat the poor computer... > > print "Guess a number." > > lo = 0 > > hi = 100 > > while True: > > gu

Re: Python as a HTTP Client

2005-11-10 Thread Fredrik Lundh
David Rasmussen wrote: > I do know about www.python.org. I do an extensive amount of googling in > general and searching at python.org before I ask questions such as this. > I did stumble upon urllib, urllib2 and httplib in the documentation, but > let me assure you, as a newbie, that finding this

Re: help make it faster please

2005-11-10 Thread Fredrik Lundh
Lonnie Princehouse wrote: > "[a-z0-9_]" means "match a single character from the set {a through z, > 0 through 9, underscore}". "\w" should be a bit faster; it's equivalent to "[a-zA-Z0-9_]" (unless you specify otherwise using the locale or unicode flags), but is handled more efficiently by the R

Re: ANN: P(x) 0.2 applet builder

2005-11-10 Thread Fredrik Lundh
Mike Meyer wrote: > Since following standards is optional on the web, at least if things > work in the most popular browser of the day, I probably should have > seen this coming. IE has no problems handling that link, if that's what you mean. judging from [ Info] Unable to open input file:

Re: exceptions, internals (introspection?)

2005-11-10 Thread Fredrik Lundh
"ej" <"ej atwellkeepercom"@bag.python.org> wrote > try: >{}['foo'] > except Exception, x: >print "class of x =", x.__class__ >print "type(x) =", type(x) >print "dir(x) =", dir(x) > >If you don't handle an exception, the interpreter will quit and print a > stack trace. What I'm

Re: Stopping Execution

2005-11-10 Thread Fredrik Lundh
James Colannino wrote: > Hey everyone. I remember from my C programming that I can either use > the exit() or return() functions to end execution of the main code > block. My question is, is there a way for me to do this in Python? I > know there has to be, but I can't for the life of me figure

Re: Stopping Execution

2005-11-10 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > import sys > sys.exit $ more test.py import sys print "should get here" sys.exit print "should never get here" $ python test.py should get here should never get here -- http://mail.python.org/mailman/listinfo/python-list

Re: different binding behavior

2005-11-10 Thread Fredrik Lundh
Gabriel Zachmann wrote: > It seems to me that the following behavior of python (2.4.1) is > inconsistent: > > >>> a=1 > >>> b=a > >>> a+=1 > >>> b > 1 > >>> a > 2 > >>> a=[1,2] > >>> b=a > >>> b+=[3] > >>> a > [1, 2, 3] > >>> b > [1, 2, 3] > > Why was it implemented like this?? assuming

Re: How to set program name in Python? ($0 in Perl)

2005-11-10 Thread Fredrik Lundh
Bengt Richter wrote: > >> > Is there a way to set the program name in Python, similar to $0 in > >> > Perl? > >> > > >> >>From `man perlvar`: > >> > > >> > $0 Contains the name of the program being executed. On some oper- > >> > ating systems assigning to "$0" modifies the argument area that

Re: Newb ??

2005-11-10 Thread Fredrik Lundh
Steven D'Aprano wrote: > Dude, that's what my code does, although I admit I took zero care to get > the awkward boundary conditions right, nor did I put code in to stop the > game after five attempts. as my simulator shows, your code needs 5.87 attempts to make a correct guess, on average. if yo

Re: derived / base class name conflicts

2005-11-10 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Now, 'i' might have already been defined by A or by the call to > A.__init__() so if you define it without knowing that, you could be > changing the behavior of A's methods in unknown ways, which is > obviously a bad thing. http://docs.python.org/tut/node11.html#SECTION

Re: thread variable scope with start_new_thread

2005-11-10 Thread Fredrik Lundh
"Luxore" <[EMAIL PROTECTED]> wrote: > I am trying to create threaded python project and I'm running into some > weird Python variable scoping. the "weird scoping" you're seeing has nothing to do with threads (read on) > I am using the "thread" module (I know, it's old and I should be using > thr

Re: Good python reference?

2005-11-11 Thread Fredrik Lundh
"derek" <[EMAIL PROTECTED]> wrote: > Hello! I'm new to the group and am looking for a decent reference for > information about the history / evolution of the Python language and > its features. Typing, scoping, etc... I'd appreciate any good links. $ tar xvfz Python-2.4.2.tgz $ cd Python-2.4.2

Re: output buffering

2005-11-11 Thread Fredrik Lundh
"JD" <[EMAIL PROTECTED]> wrote: > When reading a large datafile, I want to print a '.' to show the > progress. This fails, I get the series of '.'s after the data has been > read. Is there a trick to fix this? assuming that you're printing to stdout, sys.stdout.flush() should do the trick.

Re: how to start a process and get it's pid?

2005-11-11 Thread Fredrik Lundh
Daniel Crespo wrote: >> >>> os.spawnl(os.P_NOWAIT, "c:/windows/notepad.exe") >> 1944 > > I don't get the correct PID. > > When I do os.spawnl(os.P_NOWAIT, "c:/windows/notepad.exe") > I get 168 (for example), while in the tasklist appears notepad.exe with > the 2476 PID. > > Why? not sure, but the

Re: Newb ??

2005-11-11 Thread Fredrik Lundh
Norman Silverstone wrote: > > did you test the script? here's a simulator: > > < snip> > > Fredrik, thank you very much indeed for taking the trouble to show me the > way. I am sorry that I made the comment I did, that will teach me to read > more carefully. It is said that there is no fool like

Re: Python-based Document Management System?

2005-11-11 Thread Fredrik Lundh
W. Borgert wrote: > > If you search for CONTENT management system, there is > > Plone: A user-friendly and powerful open source Content Management ... > > http://plone.org/ > > No, I'm looking for a DMS, not a CMS. My impression from > the Plone web page is, that it does not have DMS features.

Re: PIL- error message- cannot open libtiff.so.3

2005-11-11 Thread Fredrik Lundh
Tuvas wrote: > Okay, so I've been getting this error message when trying to use PIL to > open a JPEG, that there isn't a library by the name of libtiff.so.3 . > I've been searching the documentation, there isn't any reference to > this library. Also, I don't know why it's doing this as I'm trying

Re: PIL- error message- cannot open libtiff.so.3

2005-11-11 Thread Fredrik Lundh
Tuvas wrote: > I got it from the PIL website, version 1.1.5. I guess it's possible > that there's another library Image on the computer that it could be > confusing? I'm looking for new things. Thanks! afaik, there are no unix binaries on the PIL website. did you build it yourself, from source c

Re: directory listing

2005-11-11 Thread Fredrik Lundh
"SU News Server" <[EMAIL PROTECTED]> wrote: > I've struggled with this for quite a while and I'm am just not sure > what is going on. I have the following code > import os > > def buildList( directory='/Users/mkonrad' ) > > dirs = [ ] > > listing = os.listdir(directory) > > for x in listing: >

Re: about widget construction kit

2005-11-11 Thread Fredrik Lundh
Shi Mu wrote: > I tried to install WCK(Widget Construction Kit (WCK)): > > C:\Python23>python tkinter3000-1.0-20031212\setup.py install > Traceback (most recent call last): > File "tkinter3000-1.0-20031212\setup.py", line 23, in ? > WCK_VERSION = setuplib.find_version("WCK/__init__.py") >

Re: directory listing

2005-11-11 Thread Fredrik Lundh
Michael Konrad wrote: > > for x in listing: > > print x > > if os.path.isdir(x): > > dirs.append(x) > > > > Did that and I was just getting a bunch of [ ]. if you printed "x" (the filename), that doesn't sound very likely. maybe you printed some other variable? (l

Re: about widget construction kit

2005-11-11 Thread Fredrik Lundh
Shi Mu wrote: > > > I tried to install WCK(Widget Construction Kit (WCK)): > > > > > > C:\Python23>python tkinter3000-1.0-20031212\setup.py install > > > Traceback (most recent call last): > > > File "tkinter3000-1.0-20031212\setup.py", line 23, in ? > > > WCK_VERSION = setuplib.find_version

Re: directory listing

2005-11-11 Thread Fredrik Lundh
Shi Mu wrote: > I tried this and no error reported but nothing appear on the console, why? > > import os > > def buildList( directory='c:\TEMP' ): > dirs = [ ] > listing = os.listdir(directory) > for x in listing: > x = os.path.join(directory, x) > print x > if

Re: directory listing

2005-11-11 Thread Fredrik Lundh
"Shi Mu" wrote: > but i am curious why the line of "print x" does not show > anything. because your c:\temp directory is empty ? -- http://mail.python.org/mailman/listinfo/python-list

Re: PIL- error message- cannot open libtiff.so.3

2005-11-11 Thread Fredrik Lundh
Erik Max Francis wrote: > Install libtiff. note that PIL doesn't use libtiff, so that only addresses the symtoms. (which might be good enough, of course) -- http://mail.python.org/mailman/listinfo/python-list

Re: directory listing

2005-11-11 Thread Fredrik Lundh
"Shi Mu" wrote: > print buildList() gets lots of stuffs from my temp directory(there do > exist lots of files). > But why "print x' has nothing? C:\>more script.py import os def buildList( directory='c:\TEMP' ): dirs = [ ] listing = os.listdir(directory) for x in listing: x =

Re: list of lambda

2005-11-11 Thread Fredrik Lundh
"jena" <[EMAIL PROTECTED]> wrote: > when i create list of lambdas: > l=[lambda:x.upper() for x in ['a','b','c']] > then l[0]() returns 'C', i think, it should be 'A' the "x" variable contains "c" when you leave the loop: >>> l=[lambda:x.upper() for x in ['a','b','c']] >>> x 'c' so x.upper() wil

Re: about widget construction kit

2005-11-12 Thread Fredrik Lundh
Shi Mu wrote: > I tried again and got the follwoing message: > *** cannot find Tcl/Tk headers and library files > change the TCL_ROOT variable in the setup.py file > but i have already installed TCL under python23 hmm. I still think it would be easier if you used a prebuilt version, like eve

<    1   2   3   4   5   6   7   8   9   10   >