Where can I find string.translate source?

2005-11-19 Thread bobueland
The module string has a function called translate. I tried to find the source code for that function. In: C:\Python24\Lib there is one file called string.py I open it and it says """A collection of string operations (most are no longer used). Warning: most of the code you see here isn

Re: Can a function access its own name?

2005-11-19 Thread Bengt Richter
On Sat, 19 Nov 2005 23:30:32 -0500, Mike Meyer <[EMAIL PROTECTED]> wrote: >[EMAIL PROTECTED] writes: >> Thanks Diez and Peter, >> Just what I was looking for. In "Library Reference" heading >> 3.11.1 Types and members >> Running this yields the result >> >> cap(s, n) > >You've now got three so

Re: exception raised by nested iterator being ignored by for loop

2005-11-19 Thread Bengt Richter
On Sun, 20 Nov 2005 03:36:43 GMT, james t kirk <[EMAIL PROTECTED]> wrote: >I'm writing a wrapper class to handle the line merging and filtering >for a log file analysis app > >The problem I'm running into is that the StopIteration exception >raised when the wrapped file goes past EOF isn't causing

Re: Underscores in Python numbers

2005-11-19 Thread David M. Cooke
Peter Hansen <[EMAIL PROTECTED]> writes: > Steven D'Aprano wrote: >> Dealing with numeric literals with lots of digits is >> a real (if not earth-shattering) human interface problem: it is hard for >> people to parse long numeric strings. > > I'm totally unconvinced that this _is_ a real problem,

Re: what happens when the file begin read is too big for all lines to be read with "readlines()"

2005-11-19 Thread Steven D'Aprano
On Sun, 20 Nov 2005 16:10:58 +1100, Steven D'Aprano wrote: > def get_line(filename, token): > """Returns the next line following a token, or None if not found. > Leading and trailing whitespace is ignored when looking for > the token. > """ > fp = file(filename, "r") > for

Re: what happens when the file begin read is too big for all lines to be read with "readlines()"

2005-11-19 Thread Steven D'Aprano
On Sun, 20 Nov 2005 12:28:07 +0800, Xiao Jianfeng wrote: > Let me introduce my problem I came across last night first. > > I need to read a file(which may be small or very big) and to check line > by line > to find a specific token, then the data on the next line will be what I > want. > >

Re: what happens when the file begin read is too big for all lines to be read with "readlines()"

2005-11-19 Thread Steve Holden
Xiao Jianfeng wrote: > Steven D'Aprano wrote: > > >>On Sun, 20 Nov 2005 11:05:53 +0800, Xiao Jianfeng wrote: >> >> >> >> >>>I have some other questions: >>> >>>when "fh" will be closed? >>> >>> >> >>When all references to the file are no longer in scope: >> >>def handle_file(name): >> fp =

Re: Delays getting data on sys.stdin.readline() ?

2005-11-19 Thread Mike Meyer
Christian Convey <[EMAIL PROTECTED]> writes: > I've got a program that (ideally) perpetually monitors sys.stdin for > lines of text. As soon as a line comes in, my program takes some > action. > The problem is, it seems like a very large amount of data must > accumulate on sys.stdin before even my

Re: Hot to split string literals that will across two or more lines ?

2005-11-19 Thread Steven D'Aprano
On Sat, 19 Nov 2005 22:51:04 -0500, Mike Meyer wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: >> Brackets include: >> >> parentheses or round brackets ( ) >> square brackets [ ] >> braces or curly brackets { } >> chevrons or angle brackets 〈 〉 >> >> The symbols for chevrons are not avail

Re: Underscores in Python numbers

2005-11-19 Thread Mike Meyer
Roy Smith <[EMAIL PROTECTED]> writes: > Mike Meyer <[EMAIL PROTECTED]> wrote: >> I've seen at least one language (forget which one) that allowed such >> separators, but only for groups of three. > That seems a bit silly. Not all numbers are naturally split into groups of > three. Credit card num

Re: Delays getting data on sys.stdin.readline() ?

2005-11-19 Thread Steve Holden
Christian Convey wrote: > Hello, > > I've got a program that (ideally) perpetually monitors sys.stdin for > lines of text. As soon as a line comes in, my program takes some > action. > > The problem is, it seems like a very large amount of data must > accumulate on sys.stdin before even my first

Re: Can a function access its own name?

2005-11-19 Thread Mike Meyer
[EMAIL PROTECTED] writes: > Thanks Diez and Peter, > Just what I was looking for. In "Library Reference" heading > 3.11.1 Types and members > Running this yields the result > > cap(s, n) You've now got three solutions. They'll work fine most of the time, but can't be trusted in general. Bindin

Re: Underscores in Python numbers

2005-11-19 Thread Raymond Hettinger
Gustav Hållberg wrote: > I tried finding a discussion around adding the possibility to have > optional underscores inside numbers in Python. This is a popular option > available in several "competing" scripting langauges, that I would love > to see in Python. > > Examples: > 1_234_567 > 0xdead_

Re: what happens when the file begin read is too big for all lines to be read with "readlines()"

2005-11-19 Thread Xiao Jianfeng
Steven D'Aprano wrote: >On Sun, 20 Nov 2005 11:05:53 +0800, Xiao Jianfeng wrote: > > > >> I have some other questions: >> >> when "fh" will be closed? >> >> > >When all references to the file are no longer in scope: > >def handle_file(name): >fp = file(name, "r") ># reference to file

Re: exception raised by nested iterator being ignored by for loop

2005-11-19 Thread Raymond Hettinger
james t kirk wrote: > I'm writing a wrapper class to handle the line merging and filtering > for a log file analysis app > > The problem I'm running into is that the StopIteration exception > raised when the wrapped file goes past EOF isn't causing the second > for loop to stop. Admiral Kirk, The

Re: newbie-question about a list

2005-11-19 Thread Mike Meyer
[EMAIL PROTECTED] writes: > I've seen this construct in a script [x.capitalize() for x in ['a','b', 'c']] > ['A', 'B', 'C'] > I tried to find a description of this in "Library Reference" but > couldn't find it. Could somebody direct me where this type of construct > is described. As others ha

Re: Underscores in Python numbers

2005-11-19 Thread Roy Smith
Mike Meyer <[EMAIL PROTECTED]> wrote: > I've seen at least one language (forget which one) that allowed such > separators, but only for groups of three. That seems a bit silly. Not all numbers are naturally split into groups of three. Credit card numbers are (typically) split into groups of fou

Delays getting data on sys.stdin.readline() ?

2005-11-19 Thread Christian Convey
Hello, I've got a program that (ideally) perpetually monitors sys.stdin for lines of text. As soon as a line comes in, my program takes some action. The problem is, it seems like a very large amount of data must accumulate on sys.stdin before even my first invocation of readline() returns. This

Re: Underscores in Python numbers

2005-11-19 Thread Mike Meyer
Steven D'Aprano <[EMAIL PROTECTED]> writes: > On Sat, 19 Nov 2005 13:08:57 -0500, Peter Hansen wrote: >> Umm... in other words, "the underscore is under-used so let's assign >> some arbitrary meaning to it" (to make the language more like Perl >> perhaps?). > > +1 > > I *really* don't like the id

Re: what happens when the file begin read is too big for all lines to be read with "readlines()"

2005-11-19 Thread Steven D'Aprano
On Sun, 20 Nov 2005 11:05:53 +0800, Xiao Jianfeng wrote: > I have some other questions: > > when "fh" will be closed? When all references to the file are no longer in scope: def handle_file(name): fp = file(name, "r") # reference to file now in scope do_stuff(fp) return fp f

Re: Hot to split string literals that will across two or more lines ?

2005-11-19 Thread Mike Meyer
Steven D'Aprano <[EMAIL PROTECTED]> writes: > Brackets include: > > parentheses or round brackets ( ) > square brackets [ ] > braces or curly brackets { } > chevrons or angle brackets 〈 〉 > > The symbols for chevrons are not available on common keyboards, are not > available in ordinary ASCII,

query domain registry from python?

2005-11-19 Thread randomtalk
hi, does anyone know of a library that can query domain registry or any site that provide information to such an activity? as i want to build a simple domain name searching program for my own benefit.. thanks alot :D -- http://mail.python.org/mailman/listinfo/python-list

Re: Can a function access its own name?

2005-11-19 Thread B Mahoney
Decorate any function with @aboutme(), which will print the function name each time the function is called. All the 'hello' stuff is in the aboutme() decorator code. There is no code in the decorated functions themselves doing anything to telling us the function name. # The decorator def aboutme

exception raised by nested iterator being ignored by for loop

2005-11-19 Thread james t kirk
I'm writing a wrapper class to handle the line merging and filtering for a log file analysis app The problem I'm running into is that the StopIteration exception raised when the wrapped file goes past EOF isn't causing the second for loop to stop. Wrapping the second for loop in a try/except claus

Re: Underscores in Python numbers

2005-11-19 Thread Roy Smith
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > That's a tad unfair. Dealing with numeric literals with lots of digits is > a real (if not earth-shattering) human interface problem: it is hard for > people to parse long numeric strings. There are plenty of ways to make numeric literals easier to rea

Re: what happens when the file begin read is too big for all lines to be read with "readlines()"

2005-11-19 Thread Xiao Jianfeng
[EMAIL PROTECTED] wrote: >newer python should use "for x in fh:", according to the doc : > >fh = open("your file") >for x in fh: print x > >which would only read one line at a time. > > > I have some other questions: when "fh" will be closed? And what shoud I do if I want to explicitly clos

Re: Confused about namespaces

2005-11-19 Thread Alex Martelli
KvS <[EMAIL PROTECTED]> wrote: > Thanks a lot for all the answers. After rereading everything said here > today it's become more clear to me what you guys are telling me and > I'll actively try to forget about "from ... import *" ;). I commend you for your decision. It's a construct that I somet

Re: How to write an API for a Python application?

2005-11-19 Thread Alex Martelli
Cameron Laird <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, I mumbled: > . > . > . > >Pyro might be perfect. My own instinct is to start even more > >primitively, with a minimal asynchat client and server. I've > >l

Re: path module / class

2005-11-19 Thread Peter Hansen
Neil Hodgson wrote: >To me, most uses of path.py are small incremental improvements over > os.path rather than being compelling. Do a number of small improvements > add up to be large enough to make this change? If the number of small improvements is large enough then, as with other such

Re: Python obfuscation

2005-11-19 Thread Alex Martelli
Anton Vredegoor <[EMAIL PROTECTED]> wrote: ... > Suppose I grant all your theories about optimal marketing strategies. > This still doesn't account for the way the market is behaving *now*. It > isn't in any way logical or optimal. For example in Holland (where I > live) complete governmental de

Re: Underscores in Python numbers

2005-11-19 Thread Peter Hansen
Steven D'Aprano wrote: > Dealing with numeric literals with lots of digits is > a real (if not earth-shattering) human interface problem: it is hard for > people to parse long numeric strings. I'm totally unconvinced that this _is_ a real problem, if we define "real" as being even enough to jiggl

Re: How to write an API for a Python application?

2005-11-19 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, I mumbled: . . . >Pyro might be perfect. My own instinct is to start even more >primitively, with a minimal asynchat client and server. I've >looked through the *Cookbook*, and see that it does

Re: Behaviour of enumerated types

2005-11-19 Thread Bengt Richter
On Sun, 20 Nov 2005 08:42:48 +1100 (EST), Ben Finney <[EMAIL PROTECTED]> wrote: >Bengt Richter <[EMAIL PROTECTED]> wrote: >> On Sat, 19 Nov 2005 11:10:42 +1100 (EST), Ben Finney <[EMAIL PROTECTED]> >> wrote: >> >Bengt Richter <[EMAIL PROTECTED]> wrote: >> >> If [an enumeration has a fixed sequenc

Re: Underscores in Python numbers

2005-11-19 Thread Steven D'Aprano
On Sun, 20 Nov 2005 01:39:04 +, Steve Holden wrote: > Steven D'Aprano wrote: > [...] >> Likewise, base conversion into arbitrary bases is not, in my opinion, >> common enough a task that support for it needs to be built into the syntax >> for literals. If somebody cares enough about it, write

PATH environment variable

2005-11-19 Thread mirandacascade
O/S: Win2K Vsn of Python:2.4 Based on a search of other posts in this group, it appears as though os.environ['PATH'] is one way to obtain the PATH environment variable. My questions: 1) is it correct that os.environ['PATH'] contains the PATH environment variable? 2) are there other ways to obtain

Re: Immutable instances, constant values

2005-11-19 Thread Steven D'Aprano
On Sun, 20 Nov 2005 08:56:33 +1100, Ben Finney wrote: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: >> On Fri, 18 Nov 2005 14:32:46 +1100, Ben Finney wrote: >> > Is there any difference between a Python immutable value, and a >> > constant? I suppose "constant" also implies that the *name* binds >>

Re: Underscores in Python numbers

2005-11-19 Thread [EMAIL PROTECTED]
Steven D'Aprano wrote: > That's a tad unfair. Dealing with numeric literals with lots of digits is > a real (if not earth-shattering) human interface problem: it is hard for > people to parse long numeric strings. In the wider world outside of IT, > people deal with long numeric digits by grouping

Re: Underscores in Python numbers

2005-11-19 Thread [EMAIL PROTECTED]
Steve Holden wrote: > Being European myself I am well aware of the notational differences of > the different locales, and I am perfectly happy that users can enter > numbers in their preferred format when they execute a program. > > However, I am not happy about the idea that a program source woul

Re: Underscores in Python numbers

2005-11-19 Thread Steve Holden
Steven D'Aprano wrote: [...] > Likewise, base conversion into arbitrary bases is not, in my opinion, > common enough a task that support for it needs to be built into the syntax > for literals. If somebody cares enough about it, write a module to handle > it and try to get it included with the Pyth

Re: Underscores in Python numbers

2005-11-19 Thread Steven D'Aprano
On Sat, 19 Nov 2005 13:08:57 -0500, Peter Hansen wrote: > Umm... in other words, "the underscore is under-used so let's assign > some arbitrary meaning to it" (to make the language more like Perl > perhaps?). +1 I *really* don't like the idea of allowing underscores in numeric literals. Firstl

Re: path module / class

2005-11-19 Thread Neil Hodgson
Peter Hansen: > Compelling to whom? I wonder if it's even possible for Guido to find > compelling anything which obsoletes much of os.path and shutil and > friends (modules which Guido probably added first and has used the most > and feels most comfortable with). To me, most uses of path.

Re: HTML generation vs PSP vs Templating Engines

2005-11-19 Thread has
[EMAIL PROTECTED] wrote: > I dislike embedding code or html in each other, apart from the > 'impurity' of mixing code and user interface it makes them inseparable. > > Using templates means that the code can work with different templates, > and this should be seamless, it also means that different

Re: Is there a way to create a button in either pygame or livewires?

2005-11-19 Thread Lee Harr
> Is there a way to create a button in either pygame or livewires, that is > able to be clicked and when clicked sends a command to restart the program? > You could try something like this using pygsear (http://www.nongnu.org/pygsear/) The button can call either start() which just makes a new G

Re: searching for files on Windows with Python

2005-11-19 Thread Kent Johnson
Peter Hansen wrote: > Kent Johnson wrote: >> import path >> files = path.path(pathToSearch).walkfiles(filename) > > A minor enhancement (IMHO) (though I certainly agree with Kent's > recommendation here): since there is nothing else of interest in the > "path" module, it seems to be a fairly com

Re: HTML generation vs PSP vs Templating Engines

2005-11-19 Thread Luis M. Gonzalez
I meant that it is not strictly necessary to use templates in Karrigell, although you can use Cheetah if you want. I'm not used to templates mainly because I'm familiar with the way PHP works and, for simple dynamic sites like those I work on, this is the simpliest approach. Another reason is that

Re: textwrap.dedent() drops tabs - bug or feature?

2005-11-19 Thread Peter Hansen
Steven Bethard wrote: > Thanks for double-checking this for me. I looked at expand_tabs, and > it's part of the definition of the TextWrapper class, which is not > actually used by textwrap.dedent(). So I think the textwrap.dedent() > expanding-of-tabs behavior is still basically undocumented.

Re: Immutable instances, constant values

2005-11-19 Thread Ben Finney
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Fri, 18 Nov 2005 14:32:46 +1100, Ben Finney wrote: > > Is there any difference between a Python immutable value, and a > > constant? I suppose "constant" also implies that the *name* binds > > unchangeably to a particular value. Is that meaningful? >

Re: Underscores in Python numbers

2005-11-19 Thread Steve Holden
[EMAIL PROTECTED] wrote: > Steve Holden wrote: [...] >>I really wouldn't want it to become possible to write Python code in one >>locale that had to be edited before the numeric literals were valid in >>another locale. That way madness lies. > > That is the fact, from the very beginning. 1.234 str

Re: Behaviour of enumerated types

2005-11-19 Thread Ben Finney
Bengt Richter <[EMAIL PROTECTED]> wrote: > On Sat, 19 Nov 2005 11:10:42 +1100 (EST), Ben Finney <[EMAIL PROTECTED]> > wrote: > >Bengt Richter <[EMAIL PROTECTED]> wrote: > >> If [an enumeration has a fixed sequence], what is more natural > >> than using their index values as keys to other ordered i

Re: HTML generation vs PSP vs Templating Engines

2005-11-19 Thread riplin
> No templates, no python-like or special languages, only pure and simple > python. > You can embedd python into html or, if it better suits your programming > style, you can embed html into python. Why don't you give it a try? I dislike embedding code or html in each other, apart from the 'impu

Re: Using win32ui.CreateFileDialog() to get the name of a file.

2005-11-19 Thread Joey C.
Okay, thank you. This worked very well. -- http://mail.python.org/mailman/listinfo/python-list

Re: Speeding up multiple regex matches

2005-11-19 Thread Talin
OK that worked really well. In particular, the "lastindex" property of the match object can be used to tell exactly which group matched, without having to sequentially search the list of groups. In fact, I was able to use your idea to cobble together a poor man's lexer which I am calling "reflex"

Re: Problems returning/attaching cookies

2005-11-19 Thread john . lehmann
NEVERMIND. My friend pointed out that I am simply hitting the wrong URL when trying to "test" whether I am logged in or not. The correct one is: http://www.dpreview.com/forums/editprofile.asp But I still have one question, if anyone knows -- why is it that when I print out the headers on my req

Re: Underscores in Python numbers

2005-11-19 Thread [EMAIL PROTECTED]
Steve Holden wrote: > [EMAIL PROTECTED] wrote: > > Stefan Rank wrote: > > > >>The other idea of teaching int() about separator characters has > >>internationalis/zation issues: > >>In many European countries, one would naturally try:: > >> > >> int('500.000,23') > >> > >>instead of:: > >> > >>

Re: Can a function access its own name?

2005-11-19 Thread bobueland
Thanks Diez and Peter, Just what I was looking for. In "Library Reference" heading 3.11.1 Types and members I found the info about the method you described. I also made a little function to print out not just the name of the function but also the parameter list. Here it is # fname.py im

Re: textwrap.dedent() drops tabs - bug or feature?

2005-11-19 Thread Steven Bethard
Peter Hansen wrote: > Steven Bethard wrote: > >> Note that even though the tabs are internal, they are still removed by >> textwrap.dedent(). The documentation[1] says: > > ... > >> So it looks to me like even if this is a "feature" it is undocumented. >> I'm planning on filing a bug report,

Re: Tkinter from Vis. BASIC

2005-11-19 Thread Terrance N. Phillip
[EMAIL PROTECTED] wrote: >>I want to do the same thing in Python/Tkinter: >> >> # Wait for network to recognize the workstation: >> while os.system("slist") != 0: >> self.notify["fg"] = randcolor() >> # how do I refresh label l3 at this point? >>

Re: Can you set a class instance's attributes to zero by setting the instance to zero?

2005-11-19 Thread Terry Hancock
On 19 Nov 2005 05:29:07 -0800 "Gerard Flanagan" <[EMAIL PROTECTED]> wrote: > If I have the Vector class below, is there a means by > which I can have the following behaviour > > > >>>A = Vector(1, 2) > >>>print A > (1, 2) > >>>A = 0 > >>>print A > (0, 0) As has already been mentioned, "A = 0" re

Re: Can a function access its own name?

2005-11-19 Thread Peter Hansen
[EMAIL PROTECTED] wrote: [edited slightly] > def cap(): > print "the name of this function is " + "???" > cap () sys._getframe() would help you here: >>> import sys >>> sys._getframe() >>> def f(): ... global x ... x = sys._getframe() ... >>> f() >>> x >>> dir(x) [..., 'f_bu

Re: Can a function access its own name?

2005-11-19 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Look at the code below: > > # mystringfunctions.py > > def cap(s): > print s > print "the name of this function is " + "???" > > cap ("hello") > > > Running the code above gives the following output > > >>> > hello > the name

Re: Underscores in Python numbers

2005-11-19 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > Steven D'Aprano: >>Perhaps Python should concatenate numeric literals at compile time: >>123 456 is the same as 123456. > > I think using the underscore it is more explicit: > n = 123_456 > > Alternatively the underscore syntax may be used to separate the number > from

Re: Underscores in Python numbers

2005-11-19 Thread bearophileHUGS
Roy Smith>We already have a perfectly good syntax for entering octal and hex integers, There is this syntax: 1536 == int("600", 16) that accepts strings only, up to a base of 36. There are the hex() and oct() functions. There is the %x and %o sintax, that isn't easy to remember. There are the 0x60

Re: Using win32ui.CreateFileDialog() to get the name of a file.

2005-11-19 Thread Steve Holden
Joey C. wrote: > Hello. > I'm writing a program that creates a series of batch operations to > convert movies to be used on iPodLinux. The programs that do the > encoding and conversions are seperate from mine and all mine does is > use os.system() to call the program. > > However, it needs to ge

Can a function access its own name?

2005-11-19 Thread bobueland
Look at the code below: # mystringfunctions.py def cap(s): print s print "the name of this function is " + "???" cap ("hello") Running the code above gives the following output >>> hello the name of this function is ??? >>> I would like the output

Re: Is Python weak on the web side?

2005-11-19 Thread Gerard Flanagan
Tony wrote: > If I'd like to learn Python for web-development, what are the options > available? > > Thanks. tony Nov 18th: http://groups.google.co.uk/group/comp.lang.python/browse_frm/thread/c23b12dc0edf8af0/19f859dc43c77ac1#19f859dc43c77ac1 Gerard -- http://mail.python.org/mailman/listinfo

Re: termios.tcgetattr(fd) error: (22, 'Invalid argument')

2005-11-19 Thread Petr Jakes
To provide some feedback: As Grant Edwards posted in this list, I was running my code inside of IDE that replaces sys.stdin with some other. While running the program from a shell prompt, everything goes fine. Petr Jakes -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python weak on the web side?

2005-11-19 Thread Michael Goettsche
On Sunday 20 November 2005 00:24, Tony wrote: > If I'd like to learn Python for web-development, what are the options > available? > > Thanks. tony A nice framework is CherryPy: http://www.cherrypy.org or Turbogears, which is based on CherryPy: http://www.turbogears.org/ Michael. -- http://mail.

Is Python weak on the web side?

2005-11-19 Thread Tony
If I'd like to learn Python for web-development, what are the options available? Thanks. tony -- http://mail.python.org/mailman/listinfo/python-list

Re: deleting registry keys and value

2005-11-19 Thread elbertlev
Looks OK to me. Just tried on my network - works with no exceptions -- http://mail.python.org/mailman/listinfo/python-list

Re: Obtaining an member function by name

2005-11-19 Thread guy lateur
Thanks for the feedback, people. I actually only need the "bar" part (instance methods). I added the "foo" part to generalize the question without really thinking it through first. Still, it has gotten me more information than I ever imagined. So thanks again. g -- http://mail.python.org/m

Using win32ui.CreateFileDialog() to get the name of a file.

2005-11-19 Thread Joey C.
Hello. I'm writing a program that creates a series of batch operations to convert movies to be used on iPodLinux. The programs that do the encoding and conversions are seperate from mine and all mine does is use os.system() to call the program. However, it needs to get an input file and an output

Problems returning/attaching cookies

2005-11-19 Thread john . lehmann
Attacked is a piece of code which first hits the login page successfully and receives back login cookies. But then when I attempt to hit a page which is restricted to logged in users only, I fail. That seems to be because I am not successfully re-attaching the cookies to the header portion of the

Re: what happens when the file begin read is too big for all lines to be read with "readlines()"

2005-11-19 Thread MrJean1
Just try it, it is not that hard ... ;-) /Jean Brouwers PS) Here is what happens on Linux: $ limit vmemory 1 $ python ... >>> s = file().readlines() Traceback (most recent call last): File "", line 1 in ? MemoryError >>> -- http://mail.python.org/mailman/listinfo/python-l

Re: newbie-question about a list

2005-11-19 Thread Bengt Richter
On 19 Nov 2005 07:06:30 -0800, [EMAIL PROTECTED] wrote: >I've seen this construct in a script > [x.capitalize() for x in ['a','b', 'c']] >['A', 'B', 'C'] > >I tried another myself > [x+1 for x in [1,2,3]] >[2, 3, 4] > >Apparently you can do >[function(x) for x in list] > >I tried to

Re: Underscores in Python numbers

2005-11-19 Thread Steve Holden
[EMAIL PROTECTED] wrote: > Stefan Rank wrote: > >>The other idea of teaching int() about separator characters has >>internationalis/zation issues: >>In many European countries, one would naturally try:: >> >> int('500.000,23') >> >>instead of:: >> >> int('500,000.23') > > > That is why I sai

Re: Obtaining an member function by name

2005-11-19 Thread Bengt Richter
On Sat, 19 Nov 2005 14:12:25 GMT, "guy lateur" <[EMAIL PROTECTED]> wrote: >Hi all, > >Suppose you have this class: > >class foo: >def bar(): > >Suppose you also have the strings "foo" and "bar". How can you obtain the >function foo.bar()? > >Surely somebody knows.. > Sorry, clean forgot about

Re: Obtaining an member function by name

2005-11-19 Thread EuGeNe
guy lateur wrote: > Hi all, > > Suppose you have this class: > > class foo: > def bar(): > > Suppose you also have the strings "foo" and "bar". How can you obtain the > function foo.bar()? > > Surely somebody knows.. > > TIA, > g > > Would that do? >>> class foo: @staticmeth

Re: Tkinter from Vis. BASIC

2005-11-19 Thread jmdeschamps
Terrance N. Phillip wrote: > In VB, an easy way I indicate progress is something like > do while > lblNotify.foreground = randomcolor > lblNotify.refresh <--- > > loop > > I want to do the same thing in Python/Tkinter: > > #

Re: Underscores in Python numbers

2005-11-19 Thread Roy Smith
[EMAIL PROTECTED] wrote: > Alternatively the underscore syntax may be used to separate the number > from its base: > 22875 == 22875_10 == 595b_16 == 123456_7 > But probably this is less commonly useful (and not much explicit). We already have a perfectly good syntax for entering octal and hex int

Re: newbie-question about a list

2005-11-19 Thread bobueland
This type of construct seems to be called "list comprehension". Googling for Python "list comprehension" gives a lot of hints that describe the construct. -- http://mail.python.org/mailman/listinfo/python-list

Re: Obtaining an member function by name

2005-11-19 Thread Bengt Richter
On Sat, 19 Nov 2005 14:12:25 GMT, "guy lateur" <[EMAIL PROTECTED]> wrote: >Hi all, > >Suppose you have this class: > >class foo: >def bar(): > >Suppose you also have the strings "foo" and "bar". How can you obtain the >function foo.bar()? Why don't you type these things into an interactive py

Re: examining python objects

2005-11-19 Thread rurpy
Bruno Desthuilliers wrote: > [EMAIL PROTECTED] a écrit : > > Is there a function/class/module/whatever I can use to > > look at objects? I want something that will print the object's > > value (if any) in pretty-printed form, and list all it's attributes > > and their values. And do all that rec

Re: examining python objects

2005-11-19 Thread rurpy
Bruno Desthuilliers wrote: > [EMAIL PROTECTED] a écrit : > > Is there a function/class/module/whatever I can use to > > look at objects? I want something that will print the object's > > value (if any) in pretty-printed form, and list all it's attributes > > and their values. And do all that rec

newbie-question about a list

2005-11-19 Thread bobueland
I've seen this construct in a script >>> [x.capitalize() for x in ['a','b', 'c']] ['A', 'B', 'C'] I tried another myself >>> [x+1 for x in [1,2,3]] [2, 3, 4] >>> Apparently you can do [function(x) for x in list] I tried to find a description of this in "Library Reference" but couldn't find it.

Re: PyQt layout question: QScrollView and QGridLayout?

2005-11-19 Thread Volker Lenhardt
Thank you Don, thank you David, I was convinced that there must be a simple solution at hand. A dummy widget! It does work to my needs. Don's ScrollToolView is very interesting though not yet the right tool for my actual application, but I've got some more ideas for long winter nights ... All

Tkinter from Vis. BASIC

2005-11-19 Thread Terrance N. Phillip
In VB, an easy way I indicate progress is something like do while lblNotify.foreground = randomcolor lblNotify.refresh <--- loop I want to do the same thing in Python/Tkinter: # Wait for network to recognize the workstat

Re: Underscores in Python numbers

2005-11-19 Thread [EMAIL PROTECTED]
Sybren Stuvel wrote: > [EMAIL PROTECTED] enlightened us with: > > Of course, also support the locale variant where the meaning of "," > > and "." is swapped in most European countries. > > This is exactly why I wouldn't use that notation. What happens if it > is hardcoded into the source? I mean,

Re: Underscores in Python numbers

2005-11-19 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with: > Of course, also support the locale variant where the meaning of "," > and "." is swapped in most European countries. This is exactly why I wouldn't use that notation. What happens if it is hardcoded into the source? I mean, that's what we're talking about.

Re: Obtaining an member function by name

2005-11-19 Thread Diez B. Roggisch
guy lateur wrote: > Hi all, > > Suppose you have this class: > > class foo: > def bar(): > > Suppose you also have the strings "foo" and "bar". How can you obtain the > function foo.bar()? > > Surely somebody knows.. getattr helps. However, your example won't work: it misses either a sta

Re: about try and exception

2005-11-19 Thread Sybren Stuvel
Bruno Desthuilliers enlightened us with: > (Carl's top-post corrrected. Carl, please do not top-post) If you correct people and ask them to alter their posting style, at least make sure you post in a proper way. Snip what you're not directly referring to, so people don't have to scroll in order to

Re: Obtaining an member function by name

2005-11-19 Thread [EMAIL PROTECTED]
f = getattr(obj,"bar") f() guy lateur wrote: > Hi all, > > Suppose you have this class: > > class foo: > def bar(): > > Suppose you also have the strings "foo" and "bar". How can you obtain the > function foo.bar()? > > Surely somebody knows.. > > TIA, > g -- http://mail.python.org/mailman

Obtaining an member function by name

2005-11-19 Thread guy lateur
Hi all, Suppose you have this class: class foo: def bar(): Suppose you also have the strings "foo" and "bar". How can you obtain the function foo.bar()? Surely somebody knows.. TIA, g -- http://mail.python.org/mailman/listinfo/python-list

Re: Immutable instances, constant values

2005-11-19 Thread Bengt Richter
On Sat, 19 Nov 2005 21:45:40 +1100, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >On Fri, 18 Nov 2005 14:32:46 +1100, Ben Finney wrote: > >> Is there any difference between a Python immutable value, and a >> constant? I suppose "constant" also implies that the *name* binds >> unchangeably to a parti

Re: what happens when the file begin read is too big for all lines to beread with "readlines()"

2005-11-19 Thread Fredrik Lundh
Ross Reyes wrote: > When I use readlines, what happens if the number of lines is huge?I have > a very big file (4GB) I want to read in, but I'm sure there must be some > limitation to readlines and I'd like to know how it is handled by python. readlines itself has no limitation, but it reads

Re: Can you set a class instance's attributes to zero by setting theinstance to zero?

2005-11-19 Thread Fredrik Lundh
Gerard Flanagan wrote: > If I have the Vector class below, is there a means by which I can have > the following behaviour > A = Vector(1, 2) print A > (1, 2) A = 0 that operation rebinds A; it doesn't affect the Vector instance in any way. more here: http://effbot.org/zone/pyth

Re: Can you set a class instance's attributes to zero by setting the instance to zero?

2005-11-19 Thread Diez B. Roggisch
Gerard Flanagan wrote: > Hello > > If I have the Vector class below, is there a means by which I can have > the following behaviour > > > A = Vector(1, 2) print A > > (1, 2) > A = 0 print A > > (0, 0) > > If there is such a means, will it still work with the __slots__ > attr

Can you set a class instance's attributes to zero by setting the instance to zero?

2005-11-19 Thread Gerard Flanagan
Hello If I have the Vector class below, is there a means by which I can have the following behaviour >>>A = Vector(1, 2) >>>print A (1, 2) >>>A = 0 >>>print A (0, 0) If there is such a means, will it still work with the __slots__ attribution uncommented? Thanks class Vector(object): #__s

Re: Python obfuscation

2005-11-19 Thread Anton Vredegoor
Alex Martelli wrote: > Money is made in many ways, essentially by creating (perceived) buyer > advantage and capturing some part of it -- but market segmentation is > just one of many ways. IF your predictions are ENORMOUSLY better than > those the competition can make, then offering for free "s

Re: Confused about namespaces

2005-11-19 Thread KvS
Thanks a lot for all the answers. After rereading everything said here today it's become more clear to me what you guys are telling me and I'll actively try to forget about "from ... import *" ;). -- http://mail.python.org/mailman/listinfo/python-list

Re: Web-based client code execution

2005-11-19 Thread David Wahler
Steve wrote: > AJAX works because browsers can execute javascript. I don't know of a > browser that can execute python. Basically your stuck with java or > javascript because everything else really isn't cross platform Don't jump to conclusions... http://dwahler.ky/python/ If you really, really

  1   2   >