Re: changing local namespace of a function

2005-02-05 Thread Nick Coghlan
Bo Peng wrote: By the way, will 'with statement', like the one in pascal and many other languages, be a good addition to python? For example, with d do: z = x + y would be equivalent to d['z']=d['x']+d['y'] or d.z = d.x + d.y in some other cases. This would absolutely be the *best* solution t

RE: "Collapsing" a list into a list of changes

2005-02-05 Thread Coates, Steve (ACHE)
It's not _exactly_ what you asked for but it may be enough... Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from sets import Set >>> l = [0,0,1,1,1,2,2,3,3,3,2,2,2,4,4,4,5] >>> s = Set(l) >>>

Re: PythonWin and PyWin32

2005-02-05 Thread Nick Coghlan
Chris Lott wrote: Can someone elaborate for me what the pywin32 project is exactly? Is PythonWin a replacement for idle? More to the point, do I need to worry about this as I am learning about Python, since Idle and the Windows Installer seem to work fine on my XP box? Python and IDLE work fine on

Re: who can tell me BASICS of Python

2005-02-05 Thread News M Claveau /Hamster-P
Troll ? -- http://mail.python.org/mailman/listinfo/python-list

Re: changing local namespace of a function

2005-02-05 Thread Nick Coghlan
Bo Peng wrote: I guess I will go with solution 3. It is evil but it is most close to my original intention. It leads to most readable code (except for the first line to do the magic and the last line to return result) and fastest performance. Thousands of programs use Python's class attribute ac

Re: returning True, False or None

2005-02-05 Thread TZOTZIOY
On Fri, 04 Feb 2005 13:04:16 -0500, rumours say that Steve Holden <[EMAIL PROTECTED]> might have written: [STeVe] >> For a given list: >> * If all values are None, the function should return None. >> * If at least one value is True, the function should return True. >> * Otherwise, the function sho

Re: empty classes as c structs?

2005-02-05 Thread Nick Coghlan
Steven Bethard wrote: Yes -- help me rally behind my generic object PEP which proposes a Bunch type (probably to be renamed) for the Python standard lib. =) Did you see the suggestion of 'namespace' as a name? Given that the idea is to get access to the contents using the standard Python syntax f

Re: executing VBScript from Python and vice versa

2005-02-05 Thread News M Claveau /Hamster-P
Cool. :-) And it's OK, also, for JScript (MS-Javascript) : import win32com.client vbs = win32com.client.Dispatch("ScriptControl") vbs.language = "vbscript" scode="""Function mul2(x) mul2=x*2 End Function """ vbs.addcode(scode) print vbs.eval("mul2(123)") js = win32com.client.Dispatch("ScriptC

Re: changing local namespace of a function

2005-02-05 Thread Alex Martelli
Bo Peng <[EMAIL PROTECTED]> wrote: ... > Thank again for everyone's help. I have learned a lot from the posts, > especially the wrapdict class. Hmmm, you do realize that wrapdict uses a lot of indirection while my equivalent approach, just posted, is very direct, right? To reiterate the latter

Python Processes for Win32

2005-02-05 Thread harlinseritt
I have a daemon type script (daemon.py -- we'll say) that I would like to have run continuously. I'd like to be able to do something like this: daemon.py start ... and then to have it stop I'd like to do this: daemon.py stop I am having a hard time googling for a clue as to how to accomplish th

Re: variable declaration

2005-02-05 Thread Jorgen Grahn
On Mon, 31 Jan 2005 18:49:15 +0100, Alex Martelli <[EMAIL PROTECTED]> wrote: > Michael Tobis <[EMAIL PROTECTED]> wrote: > >> With all due respect, I think "so go away if you don't like it" is >> excessive, and "so go away if you don't like it and you obviously don't >> like it so definitely go awa

Re: OT: why are LAMP sites slow?

2005-02-05 Thread EP
> > The server is slow to respond to requests. Browser rendering is > > independent of the server architecture and "slow to be fetched from > > the server" sounds like it means low network speed. I'm talking > about > > the very familiar experience of clicking a link and then waiting, > > waiti

Re: empty classes as c structs?

2005-02-05 Thread Alex Martelli
Nick Coghlan <[EMAIL PROTECTED]> wrote: ... > Michael Spencer also posted an interesting idea recently about setting up > a view of an existing dictionary, rather than as a separate object: > > class attr_view(object): >def __init__(self, data): > object.__setattr__(self, "_data", data

Re: IDLE history, Python IDE, and Interactive Python with Vim

2005-02-05 Thread Tim Hoffman
Have a gander at Boa Constructor. YOu can certainly go to a shell when debugging. (ie set breakpoint) then the shell is attached to that context. T Ashot wrote: This is sort of both Python and Vim related (which is why I've posted to both newsgroups). Python related: -- I hav

Re: FW: executing VBScript from Python and vice versa

2005-02-05 Thread Tim Hoffman
PythonWin 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32. Portions Copyright 1994-2004 Mark Hammond ([EMAIL PROTECTED]) - see 'Help/About PythonWin' for further copyright information. >>> from win32com.client import Dispatch >>> x = Dispatch("MSScriptControl.ScriptControl

Re: "Collapsing" a list into a list of changes

2005-02-05 Thread Alex Martelli
Steven Bethard <[EMAIL PROTECTED]> wrote: > Here's a solution that works for iterables other than lists: > > py> def collapse(iterable): > ... enumeration = enumerate(iterable) > ... _, lastitem = enumeration.next() > ... yield lastitem > ... for i, item in enumeration: > ...

Re: how to send an int over a socket

2005-02-05 Thread Jorgen Grahn
On 04 Feb 2005 19:24:29 -0800, Paul Rubin <> wrote: > Tom Brown <[EMAIL PROTECTED]> writes: ... > Why don't you look at the struct module instead. You could also look > the xdr or xmlrpc libraries, which may be closer to what you want. Or look at existing, successful standards like HTTP, SMTP, et

a type without a __mro__?

2005-02-05 Thread Alex Martelli
Can anybody suggest where to find (within the standard library) or how to easily make (e.g. in a C extension) a type without a __mro__, except for those (such as types.InstanceType) which are explicitly recorded in the dispatch table copy._deepcopy_dispatch...? Weird request, I know, so let me exp

Re: changing local namespace of a function

2005-02-05 Thread Alex Martelli
Bo Peng <[EMAIL PROTECTED]> wrote: > M.E.Farmer wrote: > > I really don't see your need. > > Maybe it is just my laziness. It is almost intolerable for me to write > lines and lines of code like > >d['z'] = func(d['x']+d['y']+d['whatever']['as']+d[a][0] ) > > It is ugly, unreadable and err

variable declaration

2005-02-05 Thread Alexander Zatvornitskiy
Hi Paddy! 03 Feb 2005 at 21:58, Paddy McCarthy wrote: >> Explicit' keyword! May be, python also have such a feature, I just >> don't know about it? Alexander, [EMAIL PROTECTED] PM> Advocates always say Type Checking, but so often it seems like Type PM> Constriction. - To hell with it! PM> I d

variable declaration

2005-02-05 Thread Alexander Zatvornitskiy
Привет Peter! 31 января 2005 в 09:09, Peter Otten в своем письме к All писал: PO> pychecker may help you find misspelled variable names. You have to PO> move the code into a function, though: PO> $ cat epsilon.py ...skipped... PO> $ pychecker epsilon.py PO> epsilon.py:6: Local variable (epse

An interesting python problem using Zope 2.7.3

2005-02-05 Thread ranjith g p
Greetings!!! I ran the following simple string commands in Linux + Python and the results are: [EMAIL PROTECTED] root]# python Python 2.2.2 (#1, Feb 24 2003, 19:13:11) [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>

Re: returning True, False or None

2005-02-05 Thread Alex Martelli
Brian van den Broek <[EMAIL PROTECTED]> wrote: ... > >>* If all values are None, the function should return None. > >>* If at least one value is True, the function should return True. > >>* Otherwise, the function should return False. ... > > for val in (x for x in lst if x is not None): > >

variable declaration

2005-02-05 Thread Alexander Zatvornitskiy
Hi, Alex! 31 jan 2005 at 13:46, Alex Martelli wrote: (sorry for the delay,my mail client don't highlight me your answer) AM> Since the lack of declarations is such a crucial design choice for AM> Python, then, given that you're convinced it's a very bad thing, I AM> suggest you give up Python

sos!

2005-02-05 Thread jordan2856977
hellow everybody! I'm from china. I'm a beginner of python. in china, python is not a fashionable language, so it's difficult to find some books about python. finally,I find a book named "python how to program" wrote by H.M.Deitel . who can tell me where can I find some interesting source code abou

Re: variable declaration

2005-02-05 Thread Alex Martelli
Alexander Zatvornitskiy <[EMAIL PROTECTED]> wrote: > Hi, Alex! > > 31 jan 2005 at 13:46, Alex Martelli wrote: > > (sorry for the delay,my mail client don't highlight me your answer) > > AM> Since the lack of declarations is such a crucial design choice for > AM> Python, then, given that you'r

Re: Error!

2005-02-05 Thread administrata
"John Machin" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > administrata wrote: > > I'm programming Car Salesman Program. > > It's been "3 days" learning python... > > >From whom or what book or what tutorial? > > > But, i got problem > > You got problemS. What Jeff & Brian

Re: Medical GUI Application With Python

2005-02-05 Thread John Hunter
> "Evrim" == Evrim Ozcelik <[EMAIL PROTECTED]> writes: Evrim> We are developing a medical software about PSG Evrim> (PolySomnoGraphy) analysis. The application takes signal Evrim> data from an electronic device and we will show this Evrim> continious signal function on the inte

Re: a type without a __mro__?

2005-02-05 Thread Fredrik Lundh
Alex Martelli wrote: > Can anybody suggest where to find (within the standard library) or how > to easily make (e.g. in a C extension) a type without a __mro__, except > for those (such as types.InstanceType) which are explicitly recorded in > the dispatch table copy._deepcopy_dispatch...? someth

Re: Python Processes for Win32

2005-02-05 Thread Do Re Mi chel La Si Do
Hi ! Look for "service" in PyWin @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: [EVALUATION] - E01: The Java Failure - May Python Helps?

2005-02-05 Thread Fredrik Lundh
Jan Dries wrote: >> have Pythoneers ever "banned" anyone from a public forum? it's not like >> we haven't seen trolls and crackpots before, you know. > > Well, we don't have to ban them because we have the PSU eliminate them > alltogether. So much more > efficient. Or do you think it's a coinci

Re: "Collapsing" a list into a list of changes

2005-02-05 Thread Tony
Alan McIntyre wrote: > Hi all, > > I have a list of items that has contiguous repetitions of values, but > the number and location of the repetitions is not important, so I just > need to strip them out. For example, if my original list is > [0,0,1,1,1,2,2,3,3,3,2,2,2,4,4,4,5], I want to end up

Re: returning True, False or None

2005-02-05 Thread Steve Holden
Christos TZOTZIOY Georgiou wrote: On Fri, 04 Feb 2005 13:04:16 -0500, rumours say that Steve Holden <[EMAIL PROTECTED]> might have written: [STeVe] For a given list: * If all values are None, the function should return None. * If at least one value is True, the function should return True. * Otherw

Re: Error!

2005-02-05 Thread Steve Holden
administrata wrote: "John Machin" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... administrata wrote: I'm programming Car Salesman Program. It's been "3 days" learning python... From whom or what book or what tutorial? But, i got problem You got problemS. What Jeff & Brian wrote,

Re: An interesting python problem using Zope 2.7.3

2005-02-05 Thread Steve Holden
ranjith g p wrote: Greetings!!! I ran the following simple string commands in Linux + Python and the results are: [EMAIL PROTECTED] root]# python Python 2.2.2 (#1, Feb 24 2003, 19:13:11) [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2 Type "help", "copyright", "credits" or "license" for mor

Re: sos!

2005-02-05 Thread Steve Holden
jordan2856977 wrote: hellow everybody! I'm from china. I'm a beginner of python. in china, python is not a fashionable language, so it's difficult to find some books about python. finally,I find a book named "python how to program" wrote by H.M.Deitel . who can tell me where can I find some interes

Re: returning True, False or None

2005-02-05 Thread Steve Holden
Steve Holden wrote: Christos TZOTZIOY Georgiou wrote: On Fri, 04 Feb 2005 13:04:16 -0500, rumours say that Steve Holden <[EMAIL PROTECTED]> might have written: [STeVe] For a given list: * If all values are None, the function should return None. * If at least one value is True, the function should r

Re: variable declaration

2005-02-05 Thread Roy Smith
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Alexander Zatvornitskiy) wrote: > And, one more question: do you think code like this: > > var S=0 > var eps > > for eps in xrange(10): > S=S+ups > > is very bad? Please explain your answer:) Let me answer that by way of counter-example.

Re: mounting a filesystem?

2005-02-05 Thread Georg Brandl
Dan Stromberg wrote: > Is there a python module that can mount a filesystem? > > More specifically, a loopback filesystem with a particular offset, under > linux? Why don't you just call the mount command via os.system, one of the popen methods or one of the commands.* methods? Georg -- http://

Re: "Collapsing" a list into a list of changes

2005-02-05 Thread Alan McIntyre
Steve, Yeah, in this particular application the ordering and reoccurrence of a value in a non-contiguous way does matter; if those two things weren't required I think the method you suggested would be a good way to remove the duplicates. Thanks! Coates, Steve (ACHE) wrote: It's not _exactly_ wh

Trouble converting hex to decimal?

2005-02-05 Thread Earl Eiland
I'm trying to process the IP packet length field, as recorded by pcap (Ethereal) and recovered using pcapy. When I slice out those bytes, I get a value that shows in '\x00' format, rather than '0x00'. Neither int() nor eval() are working. How do I handle this? Earl Eiland -- http://mail.pytho

Re: "Collapsing" a list into a list of changes

2005-02-05 Thread Alan McIntyre
Tony, Actually I only want to remove a certain kind of duplication; if an item occurs twice - say like this: [1,1,1,2,2,2,1,1,1], then I need to keep the order and occurrence of the individual values: [1,2,1]. Using a dict as you proposed loses the order of occurrence, as well as multiple occu

Re: "Collapsing" a list into a list of changes

2005-02-05 Thread Alan McIntyre
Alex, Wow, that method turns out to be the fastest so far in a simple benchmark on Python2.3 (on my machine, of course, YMMV); it takes 14% less time than the one that I deemed most straightforward. :) Thanks, Alan Alex Martelli wrote: H, what role does the enumeration play here? I don't se

Re: Trouble converting hex to decimal?

2005-02-05 Thread Steve Holden
Earl Eiland wrote: I'm trying to process the IP packet length field, as recorded by pcap (Ethereal) and recovered using pcapy. When I slice out those bytes, I get a value that shows in '\x00' format, rather than '0x00'. Neither int() nor eval() are working. How do I handle this? Earl Eiland You

Re: Trouble converting hex to decimal?

2005-02-05 Thread Alan McIntyre
Earl, Try this: >>> ord('\x00') 0 or: >>> import struct >>> struct.unpack('b', '\x00') (0,) If you're needing to pull values out of multiple bytes (shorts, longs, floats, etc.), have a look at the struct module. Here's an example: >>> struct.unpack('f', '\x00\x00(B') (42.0,) Hope this helps, Alan

Re: IDLE history, Python IDE, and Interactive Python with Vim

2005-02-05 Thread Pat
Ashot wrote: > This is sort of both Python and Vim related (which is why I've posted to > both newsgroups). > > Python related: > -- > I have been frustrated for quite some time with a lack of a history > command in IDLE (in fact with IDLE in general). Often I'll develop new >

Re: variable declaration

2005-02-05 Thread Peter Otten
Alexander Zatvornitskiy wrote: > ÐÑÐÐÐÑ Peter! > > 31 ÑÐÐÐÑÑ 2005 Ð 09:09, Peter Otten Ð Ñ ÐÐÑÑÐÐ Ð All > ÐÐÑÐÐ: > PO> pychecker may help you find misspelled variable names. You have to > PO> move the code into a function, though: > > PO> $ cat epsilon.py > ...skipped... > PO> $ pycheck

Re: sos!

2005-02-05 Thread Bruno Desthuilliers
jordan2856977 a écrit : hellow everybody! I'm from china. I'm a beginner of python. in china, python is not a fashionable language, so it's difficult to find some books about python. finally,I find a book named "python how to program" wrote by H.M.Deitel . who can tell me where can I find some inte

Re: who can tell me BASICS of Python

2005-02-05 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : I want to know which compiler I can use ... thank you To compile what ? Python code ? The compiler is in the standard lib. -- http://mail.python.org/mailman/listinfo/python-list

Re: [EVALUATION] - E01: The Java Failure - May Python Helps?

2005-02-05 Thread Ilias Lazaridis
Jeremy Bowers wrote: On Thu, 03 Feb 2005 09:26:08 +0200, Ilias Lazaridis wrote: My question is essentially: How many of those constructs are already supported by python (and the surrounding open-source-projects): http://lazaridis.com/case/stack/index.html This post is hard to follow, but I'm goin

Re: Error!

2005-02-05 Thread Bruno Desthuilliers
Steve Holden a écrit : (snip) So, for example, your program might look like this: base_price = int(raw_input(...)) tax_rate = int(raw_input(...) tax_amount = base_price * ((100+tax_amount)/...) s/(100+tax_amount)/(100 + tax_rate)/, I guess ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Error!

2005-02-05 Thread Steve Holden
Bruno Desthuilliers wrote: Steve Holden a écrit : (snip) So, for example, your program might look like this: base_price = int(raw_input(...)) tax_rate = int(raw_input(...) tax_amount = base_price * ((100+tax_amount)/...) s/(100+tax_amount)/(100 + tax_rate)/, I guess ? Oops. Let's try tax_amount = b

Re: empty classes as c structs?

2005-02-05 Thread Carlos Ribeiro
On Sat, 05 Feb 2005 02:38:13 -0500, Leif K-Brooks <[EMAIL PROTECTED]> wrote: > Actually, in Python, class definitions are runtime executable statements > just like any other. You can do this: > > >>> def make_class(with_spam=True): > ... if with_spam: > ... class TheClass(object): > ...def

Re: a type without a __mro__?

2005-02-05 Thread Nick Coghlan
Fredrik Lundh wrote: Alex Martelli wrote: Can anybody suggest where to find (within the standard library) or how to easily make (e.g. in a C extension) a type without a __mro__, except for those (such as types.InstanceType) which are explicitly recorded in the dispatch table copy._deepcopy_dispatc

variable declaration

2005-02-05 Thread Alexander Zatvornitskiy
Hi, Alex! 05 feb 2005 at 12:52, Alex Martelli wrote: >> declarations, another (this problem is common with C/C++) >> is: === print 1/2 0 === (I understand why it is so, but I don't like >> it anyway. Such behaviour also can cause some hard-to-find-bugs) AM> You're conflating a fundamental, cru

Re: a type without a __mro__?

2005-02-05 Thread Alex Martelli
Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > > Can anybody suggest where to find (within the standard library) or how > > to easily make (e.g. in a C extension) a type without a __mro__, except ^^ > > for those (such as types.I

Re: changing local namespace of a function

2005-02-05 Thread Nick Coghlan
Alex Martelli wrote: Bo Peng <[EMAIL PROTECTED]> wrote: ... Thank again for everyone's help. I have learned a lot from the posts, especially the wrapdict class. Hmmm, you do realize that wrapdict uses a lot of indirection while my equivalent approach, just posted, is very direct, right? To rei

Re: empty classes as c structs?

2005-02-05 Thread Nick Coghlan
Alex Martelli wrote: Nick Coghlan <[EMAIL PROTECTED]> wrote: ... Michael Spencer also posted an interesting idea recently about setting up a view of an existing dictionary, rather than as a separate object: class attr_view(object): def __init__(self, data): object.__setattr__(self, "_data"

Re: [EVALUATION] - E01: The Java Failure - May Python Helps?

2005-02-05 Thread Stephen Kellett
In message <[EMAIL PROTECTED]>, Ilias Lazaridis <[EMAIL PROTECTED]> writes [I like to avoid interaction with google.] Well, use a different search engine. I've not evaluated Java. That is strange - the title of this thread indicates that you have evaluated Java. You have posted similar threads in

Re: variable declaration

2005-02-05 Thread Alex Martelli
Alexander Zatvornitskiy <[EMAIL PROTECTED]> wrote: ... > AM> The fact that in Python there are ONLY statements, NO declarations, > === > def qq(): > global z > z=5 > === > What is "global"? Statement? Ok, I fill lack of "var" statement:) 'global' is an ugly wart, to all intents and purposes

Re: changing local namespace of a function

2005-02-05 Thread Kent Johnson
Bo Peng wrote: Dear list, I have many dictionaries with the same set of keys and I would like to write a function to calculate something based on these values. For example, I have a = {'x':1, 'y':2} b = {'x':3, 'y':3} def fun(dict): dict['z'] = dict['x'] + dict['y'] fun(a) and fun(b) will set

Re: changing local namespace of a function

2005-02-05 Thread Bo Peng
Nick Coghlan wrote: If you want to add more calculated properties to the data manipulator, simply define additional calculator methods, and define the attribute with make_prop. This has became really appealing You know, I have a deep root in C/C++ so performance is the king and hacking is pa

Re: changing local namespace of a function

2005-02-05 Thread Kent Johnson
Bo Peng wrote: Yes. I thought of using exec or eval. If there are a dozen statements, def fun(d): exec 'z = x + y' in globals(), d seems to be more readable than def fun(d): d['z'] = d['x'] + d['y'] But how severe will the performance penalty be? You can precompile the string using compile(), y

Re: variable declaration

2005-02-05 Thread Nick Coghlan
Alexander Zatvornitskiy wrote: You wrote about "substantial cost" of var declarations. Yes, you are write. But think about the cost of lack of var declarations. Compare time that programmer will waste on search for the reason of bug caused by such typo, plus time what programmer will waste while re

Re: variable declaration

2005-02-05 Thread Nick Coghlan
Alex Martelli wrote: 'global' is an ugly wart, to all intents and purposes working "as if" it was a declaration. If I had to vote about the one worst formal defect of Python, it would surely be 'global'. Fortunately, it's reasonably easy to avoid the ugliness, by avoiding rebinding (within functio

Re: Trouble converting hex to decimal?

2005-02-05 Thread Pedro Werneck
Hi The problem is that '\x00' is a escape sequence... Try something like this: >>> x = '\x00' >>> int(repr(x)[3:-1], 16) 0 >>> x = '\x15' >>> int(repr(x)[3:-1], 16) 21 >>> On Sat, 05 Feb 2005 06:51:32 -0700 Earl Eiland <[EMAIL PROTECTED]> wrote: > I'm trying to process the IP packet lengt

Re: "Collapsing" a list into a list of changes

2005-02-05 Thread Jack Diederich
On Sat, Feb 05, 2005 at 02:31:08PM +1000, Nick Coghlan wrote: > Jack Diederich wrote: > >Since this is 2.4 you could also return a generator expression. > > > > > def iter_collapse(myList): > > > >... return (x[0] for (x) in > >it.groupby([0,0,1,1,1,2,2,3,3,3,2,2,2,4,4,4,5])) > >... > > Bu

Re: variable declaration

2005-02-05 Thread Nick Coghlan
Alexander Zatvornitskiy wrote: var epsilon=0 var S S=0 while epsilon<10: S=S+epsilon epselon=epsilon+1#interpreter should show error here,if it's in "strict mode" print S It is easy, and clean-looking. Alexander, [EMAIL PROTECTED] An alternate proposal, where the decision to request rebinding s

Re: changing local namespace of a function

2005-02-05 Thread Nick Coghlan
Bo Peng wrote: I can not say enough thank you for this. Don't thank me, thank Guido. He created the property machinery - I just let you know it was there :) But yes, Python's OO is OO the way it should be - something that helps you get the job done quickly and cleanly, rather than making you jum

How to read POSTed data

2005-02-05 Thread Håkan Persson
Hi. I am trying to set up a simple HTTP-server but I have problems reading data that is beeing POSTed. class httpServer(BaseHTTPServer.BaseHTTPRequestHandler): def do_POST(self): input = self.rfile.read() The self.rfile.read() will hang on the data = self._sock.recv(recv_size) line in t

Re: Trouble converting hex to decimal?

2005-02-05 Thread Steve Holden
Pedro Werneck wrote: Hi The problem is that '\x00' is a escape sequence... Try something like this: x = '\x00' int(repr(x)[3:-1], 16) 0 x = '\x15' int(repr(x)[3:-1], 16) 21 On Sat, 05 Feb 2005 06:51:32 -0700 Earl Eiland <[EMAIL PROTECTED]> wrote: I'm trying to process the IP packet length fiel

Re: changing local namespace of a function

2005-02-05 Thread Nick Coghlan
Something I forgot to mention. . . Bo Peng wrote: You know, I have a deep root in C/C++ so performance is the king and hacking is part of my daily life. Time to change now. :) The entire design of C++ is in many ways a regrettable monument to the idea that premature optimisation is evil - far too

An Ode To My Two Loves

2005-02-05 Thread Jamey Cribbs
At the risk of calling my manhood into question, I humbly submit the following little diddy (which is a blatant rip-off of a heart wrenching melody of the '70s by that international superstar, Mary Macgregor): To the tune of "Torn Between Two Lovers": Torn between two languages, both o

Re: How do I enter/receive webpage information?

2005-02-05 Thread Jorgen Grahn
On 4 Feb 2005 15:33:50 -0800, Mudcat <[EMAIL PROTECTED]> wrote: > Hi, > > I'm wondering the best way to do the following. > > I would like to use a map webpage (like yahoo maps) to find the > distance between two places that are pulled in from a text file. I want > to accomplish this without disp

Re: Trouble converting hex to decimal?

2005-02-05 Thread Jorgen Grahn
On Sat, 05 Feb 2005 06:51:32 -0700, Earl Eiland <[EMAIL PROTECTED]> wrote: > I'm trying to process the IP packet length field, as recorded by pcap > (Ethereal) and recovered using pcapy. When I slice out those bytes, I > get a value that shows in '\x00' format, rather than '0x00'. Neither > int()

Re: variable declaration

2005-02-05 Thread Alex Martelli
Nick Coghlan <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > 'global' is an ugly wart, to all intents and purposes working "as if" it > > was a declaration. If I had to vote about the one worst formal defect > > of Python, it would surely be 'global'. > > > > Fortunately, it's reasonably e

Re: IDLE history, Python IDE, and Interactive Python with Vim

2005-02-05 Thread Fernando Perez
Hi, Ashot wrote: > This is sort of both Python and Vim related (which is why I've posted to > both newsgroups). [...] I know you've been using ipython recently (the readline color bugs), so perhaps my reply is a bit redundant. Forgive me if that's the case, I just want to give you some useful

Re: variable declaration

2005-02-05 Thread Arthur
On Sat, 5 Feb 2005 17:00:15 +0100, [EMAIL PROTECTED] (Alex Martelli) wrote: > >I consider this one of the worst ideas to have been proposed on this >newsgroup over the years, which _IS_ saying something. \ I would disagree, but only to the extent that nothing that is only a request for an option t

Alternative to standard C "for"

2005-02-05 Thread adomas . paltanavicius
Hi there, I am quite new to Python, and have a straight & simple question. In C, there is for (init; cond; advance). We all know that. In Python there are two ways to loop over i=A..B (numerical.): 1) i = A while ihttp://mail.python.org/mailman/listinfo/python-list

Re: Alternative to standard C "for"

2005-02-05 Thread BJörn Lindqvist
> I am quite new to Python, and have a straight & simple question. > In C, there is for (init; cond; advance). We all know that. > In Python there are two ways to loop over i=A..B (numerical.): > 1) i = A >while i ...do something... > i+=STEP This is indeed quite ugly. You rarely n

Re: Alternative to standard C "for"

2005-02-05 Thread Paul Rubin
[EMAIL PROTECTED] writes: > problem. If i do ..in range(1, 1).. (what I really need > sometimes), it takes few hundred megs of memory and slows > down. Are there other good ways for this simple problem? Generators? use xrange instead of range. -- http://mail.python.org/mailman/listinfo/py

Re: Alternative to standard C "for"

2005-02-05 Thread Daniel Bickett
[EMAIL PROTECTED] wrote: > Are there other good ways for this simple problem? Generators? Very interesting problem :) That never occured to me. To prevent python from loading that entire list into memory, one could, as you suggested, use a generator: >>> def genrange( start , stop , step = 1 ):

Re: Alternative to standard C "for"

2005-02-05 Thread Daniel Bickett
Paul Rubin wrote: > use xrange instead of range. Woops ;) I wasn't aware such a function existed. apologies-for-reinventing-the-wheel-ly y'rs, -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: variable declaration

2005-02-05 Thread Alex Martelli
Arthur <[EMAIL PROTECTED]> wrote: > On Sat, 5 Feb 2005 17:00:15 +0100, [EMAIL PROTECTED] (Alex Martelli) > wrote: > > > >I consider this one of the worst ideas to have been proposed on this > >newsgroup over the years, which _IS_ saying something. \ > > I would disagree, but only to the extent th

Re: Alternative to standard C "for"

2005-02-05 Thread Georg Brandl
BJörn Lindqvist wrote: >> I am quite new to Python, and have a straight & simple question. >> In C, there is for (init; cond; advance). We all know that. >> In Python there are two ways to loop over i=A..B (numerical.): >> 1) i = A >>while i> ...do something... >> i+=STEP > > This

Re: changing local namespace of a function

2005-02-05 Thread Michael Spencer
Alex Martelli wrote: Hmmm, you do realize that wrapdict uses a lot of indirection while my equivalent approach, just posted, is very direct, right? To reiterate the latter, and dress it up nicely too, it's class wrapwell(object): def __init__(self, somedict): self.__dict__ = somedict B

Re: empty classes as c structs?

2005-02-05 Thread Steven Bethard
Nick Coghlan wrote: Steven Bethard wrote: Yes -- help me rally behind my generic object PEP which proposes a Bunch type (probably to be renamed) for the Python standard lib. =) Did you see the suggestion of 'namespace' as a name? Yup, it's in the current PEP draft. See the "Open Issues" section:

Re: Alternative to standard C "for"

2005-02-05 Thread Diez B. Roggisch
> First case looks quite nasty, because it's for more complicated > things, not numerical loops. Second is very nice, but with there's > problem. If i do ..in range(1, 1).. (what I really need > sometimes), it takes few hundred megs of memory and slows > down. Are there other good ways for

Re: empty classes as c structs?

2005-02-05 Thread Steven Bethard
Nick Coghlan wrote: Alex Martelli wrote: Nick Coghlan <[EMAIL PROTECTED]> wrote: ... Michael Spencer also posted an interesting idea recently about setting up a view of an existing dictionary, rather than as a separate object: class attr_view(object): def __init__(self, data): object.__s

Which IDE supports python and wxpython?

2005-02-05 Thread Selfimprover
Hello all, Is there a good IDE on the market which supports python and wxpython. Goal is to use it in a big distributed project. Greetings -- http://mail.python.org/mailman/listinfo/python-list

Re: Alternative to standard C "for"

2005-02-05 Thread Alex Martelli
Georg Brandl <[EMAIL PROTECTED]> wrote: > Slight terminology glitch -- it does return an iterator, not a > generator. Generators are functions that return iterators. xrange returns an ITERABLE, not an ITERATOR. Videat: >>> a = xrange(23, 43) >>> a.next() Traceback (most recent call last): Fil

Re: Which IDE supports python and wxpython?

2005-02-05 Thread Daniel Bickett
I know of two: Boa Constructor: http://boa-constructor.sourceforge.net/ wxGlade: http://wxglade.sourceforge.net/ -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list

access problem with DCOM server written in python

2005-02-05 Thread Achim Domma (Procoders)
Hi, I have a problem with a DCOM server written in python. Here is my minimal test object: class TestObject: _reg_clsid_ = "{ECDBB3BC-F0BF-4eef-87C0-D179A928DAB5}" _reg_progid_ = "DComTest.Object" _reg_desc_ = "DComTest.Object" _public_methods_ = ['testit'] def __init__(self):

Re: Alternative to standard C "for"

2005-02-05 Thread Georg Brandl
Alex Martelli wrote: > Georg Brandl <[EMAIL PROTECTED]> wrote: > >> Slight terminology glitch -- it does return an iterator, not a >> generator. Generators are functions that return iterators. > > xrange returns an ITERABLE, not an ITERATOR. Videat: > a = xrange(23, 43) a.next() > Tra

Re: "Collapsing" a list into a list of changes

2005-02-05 Thread Tony
Alan McIntyre wrote: > Tony, > > Actually I only want to remove a certain kind of duplication; How about this one liner? def condense(m): print [m[0]]+[m[k] for k in range(1,len(m)) if m[k]!=m[k-1]] b=[1,1,1,2,2,2,1,1,1] condense(b) Tony Clarke -- http://mail.python.org/mai

Re: [EVALUATION] - E01: The Java Failure - May Python Helps?

2005-02-05 Thread Jeremy Bowers
On Sat, 05 Feb 2005 16:44:11 +0200, Ilias Lazaridis wrote: >> * Deployment: I don't generally have enough problems with this to be >> worth thinking about. I don't know what the state of the remote >> debugging is on Python; Google "remote debugging Python". > > [I like to avoid interaction with g

Re: empty classes as c structs?

2005-02-05 Thread Michael Spencer
Alex Martelli wrote: Nick Coghlan <[EMAIL PROTECTED]> wrote: ... Michael Spencer also posted ... Wasted indirection, IMHO. A better implementation: class attr_view(object): def __init__(self, data): self.__dict__ = data Alex Indeed! A complete brain-blip Michael -- http://mail.pyth

Re: empty classes as c structs?

2005-02-05 Thread Michael Spencer
Steven Bethard wrote: Nick Coghlan wrote: class attr_view(object): def __init__(self, data): self.__dict__ = data I think the idea definitely deserves mention as a possible implementation strategy in the generic objects PEP, with the data argument made optional: That's basically wh

Re: Which IDE supports python and wxpython?

2005-02-05 Thread http://www.stani.be
Try SPE, I just released (GPL) a new version: http://spe.pycs.net Stani http://www.stani.be -- http://mail.python.org/mailman/listinfo/python-list

Re: empty classes as c structs?

2005-02-05 Thread Brian van den Broek
Steven Bethard said unto the world upon 2005-02-05 14:05: Nick Coghlan wrote: Steven Bethard wrote: Yes -- help me rally behind my generic object PEP which proposes a Bunch type (probably to be renamed) for the Python standard lib. =) Did you see the suggestion of 'namespace' as a name? Yup, it'

  1   2   >