Re: sqlite utf8 encoding error

2005-11-19 Thread Manlio Perillo
On 18 Nov 2005 09:09:24 -0800, Greg Miller [EMAIL PROTECTED] wrote: Thank you for all your suggestions. I ended up casting the string to unicode prior to inserting into the database. Don't do it by hand if it can be done by an automated system. Try with: from pysqlite2 import dbapi2 as

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

2005-11-19 Thread Petr Jakes
On my box (Fedora Core4, Python 2.4.1) I am getting following error: import termios, sys fd = sys.stdin.fileno() oldSettings = termios.tcgetattr(fd) Traceback (innermost last): File stdin, line 1, in ? error: (22, 'Invalid argument') Thanks for your comments. Petr Jakes --

Re: Reinvent no more forever

2005-11-19 Thread Ben Finney
[EMAIL PROTECTED] wrote: Ben Finney wrote: How do we deal with the rampant proliferation of a zillion implementations of some standard idiom in PyPI? How about some kind of mega util package? One big package with all those recurring reinventions. If it gets popular enough, I'm sure it

Re: Underscores in Python numbers

2005-11-19 Thread Stefan Rank
on 19.11.2005 06:56 Steven D'Aprano said the following: [snip] Perhaps Python should concatenate numeric literals at compile time: 123 456 is the same as 123456. Off the top of my head, I don't think this should break any older code, because 123 456 is not currently legal in Python. +1

Re: Underscores in Python numbers

2005-11-19 Thread bearophileHUGS
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 its base: 22875 == 22875_10 == 595b_16

Re: the PHP ternary operator equivalent on Python

2005-11-19 Thread [EMAIL PROTECTED]
Steven D'Aprano wrote: L = [zero if n == 0 else \ negative + (odd if n % 2 else even) if n 0 else \ odd if n % 2 else even for n in range(8)] BTW, the continuation is not necessary I believe. [ x==0 and zero or [,-][x 0] + (even, odd)[x%2] for x in range(8) ] isn't too bad.

Re: about try and exception

2005-11-19 Thread Bruno Desthuilliers
Shi Mu a écrit : On 11/17/05, Carl J. Van Arsdall [EMAIL PROTECTED] wrote: (Carl's top-post corrrected. Carl, please do not top-post) Ben Bush wrote: I wrote the following code to test the use of try...exception, and I want n to be printed out. However, the following code's output is:

Re: Underscores in Python numbers

2005-11-19 Thread [EMAIL PROTECTED]
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 said Of course, also support the locale variant

Re: examining python objects

2005-11-19 Thread Bruno Desthuilliers
[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 recursively. I want to be able to find out

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

2005-11-19 Thread Piet van Oostrum
Duncan Grisby [EMAIL PROTECTED] (DG) wrote: DG In article [EMAIL PROTECTED], DG Piet van Oostrum [EMAIL PROTECTED] wrote: A more lightweight solution might be Ice. http://www.zeroc.com/ice.html It is architecturally similar to Corba, but with less overhead. DG More lightweight and less

Re: Confused about namespaces

2005-11-19 Thread Bruno Desthuilliers
KvS a écrit : Ok, makes sense but didn't seem natural to me, It will seem more natural if you understand that modules should be modulars (ie: low coupling, high cohesion). A module should *never* bother about no rely upon other modules being imported by the module it imports itself. Err, not

Re: Immutable instances, constant values

2005-11-19 Thread Steven D'Aprano
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? That's precisely how I understand constant to be

Re: Underscores in Python numbers

2005-11-19 Thread Steven D'Aprano
On Sat, 19 Nov 2005 01:33:40 -0800, bearophileHUGS 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 It is also easy to make a typo: n = 123-456 --

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

2005-11-19 Thread Ross Reyes
HI - Sorry for maybe a too simple a question but I googled and also checked my reference O'Reilly Learning Python book and I did not find a satisfactory answer. 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

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

2005-11-19 Thread [EMAIL PROTECTED]
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. Ross Reyes wrote: HI - Sorry for maybe a too simple a question but I googled and also checked my reference O'Reilly Learning Python book and I did

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

2005-11-19 Thread Ben Finney
Ross Reyes [EMAIL PROTECTED] wrote: Sorry for maybe a too simple a question but I googled and also checked my reference O'Reilly Learning Python book and I did not find a satisfactory answer. The Python documentation is online, and it's good to get familiar with it:

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

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: 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

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): #__slots__ =

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__ attribution uncommented? No, you

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/python-objects.htm

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: 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 particular

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: 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 --

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 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

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. Then

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, that's what

Tkinter from Vis. BASIC

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

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 ...

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. Could

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

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

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 python session and

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: 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

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 some process is not met lblNotify.foreground = randomcolor lblNotify.refresh --- sleep loop I want to do the same thing in

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: @staticmethod def bar():

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 the strings.

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 said Of course, also

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 find a description of

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(bugfile).readlines() Traceback (most recent call last): File stdin, line 1 in ? MemoryError --

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

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

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 --

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

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: 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. --

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 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 --

Re: Underscores in Python numbers

2005-11-19 Thread bearophileHUGS
Roy SmithWe 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 0x600

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 its base:

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 of this function is ???

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() frame object at 0x00B496D0 def f(): ... global x ... x = sys._getframe() ... f() x frame object at

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 rebinds the name A to the

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? time.sleep(3)

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, but I wanted

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

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:: int('500,000.23') That

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

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: 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: 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

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 info? I don't

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 striaightly

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? That's

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: 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: 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 common idiom

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

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 code

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.py

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. Firstly,

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 Python

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 would

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: 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 unchangeably

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

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 a

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 sequence], what is more

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 jiggle my

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

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: 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 looked through

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 sometimes

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 close the file

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 read

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

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

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: 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, and may

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: 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 idea of allowing

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 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 four.

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 have pointed

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: 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 now in scope

  1   2   >