Re: Trouble converting hex to decimal?

2005-02-05 Thread Miki Tebeka
Hello Earl, > 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? Try using "arr

Re: variable declaration

2005-02-05 Thread Alex Martelli
Arthur <[EMAIL PROTECTED]> wrote: > Do the STUPID firms use Python as well. Yes, they're definitely starting to do so. > Why? The single most frequent reason is that some techie sneaked it in, for example "just for testing" or "to do a prototype" or even without any actual permission. Firms

Multiple constructors

2005-02-05 Thread Philip Smith
Call this a C++ programmers hang-up if you like. I don't seem to be able to define multiple versions of __init__ in my matrix class (ie to initialise either from a list of values or from 2 dimensions (rows/columns)). Even if Python couldn't resolve the __init__ to use on the basis of argument

Re: Trouble converting hex to decimal?

2005-02-05 Thread Adam DePrince
On Sat, 2005-02-05 at 12:02, Steve Holden wrote: > Pedro Werneck wrote: > > 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 -070

Re: How do I convert arithemtic string (like "2+2") to a number?

2005-02-05 Thread Michael Hartl
Adam brings up a good point: eval is a very general function which evaluates an arbitrary Python expression. As a result, it (and its close cousin exec) should be used with caution if security is an issue. Michael -- http://mail.python.org/mailman/listinfo/python-list

Re: variable declaration

2005-02-05 Thread Alex Martelli
Nick Coghlan <[EMAIL PROTECTED]> wrote: ... > > _temp = x.y > > x.y = type(temp).__irebind__(temp, z) ... > I was thinking of something simpler: > >x.y >x.y = z > > That is, before the assignment attempt, x.y has to resolve to *something*, but > the interpreter isn't particu

Word for a non-iterator iterable?

2005-02-05 Thread Leif K-Brooks
Is there a word for an iterable object which isn't also an iterator, and therefor can be iterated over multiple times without being exhausted? "Sequence" is close, but a non-iterator iterable could technically provide an __iter__ method without implementing the sequence protocol, so it's not qu

Re: How do I convert arithemtic string (like "2+2") to a number?

2005-02-05 Thread Adam DePrince
On Sat, 2005-02-05 at 17:11, Michael Hartl wrote: > Use the eval function: > > >>> eval("30/(6+9)") > 2 > > Michael Sure, if you trust the source of the string you are evaluating. If this is a form submission on your web site, be wary of the nefarious user who might submit to you: commands.get

Re: changing local namespace of a function

2005-02-05 Thread Bo Peng
Kent Johnson wrote: Bo Peng wrote: Exec is slow since compiling the string and calls to globals() use a lot of time. The last one is most elegant but __getattr__ and __setattr__ are costly. The 'evil hack' solution is good since accessing x and y takes no additional time. Previous comparison w

Re: CGI POST problem was: How to read POSTed data

2005-02-05 Thread Dan Perl
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dan Perl wrote: > >> how is a multipart POST request parsed by CGIHTTPServer? > > It isn't; the input stream containing the multipart/form-data content > is passed to the CGI script, which can choose to parse it or not using > any code

Re: a type without a __mro__?

2005-02-05 Thread John Lenton
On Sat, Feb 05, 2005 at 11:37:10AM +0100, 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

Re: sos!

2005-02-05 Thread Dan Perl
"jordan2856977" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Dan Perl" <[EMAIL PROTECTED]> wrote in message > news:<[EMAIL PROTECTED]>... >> <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> > >> > Dan Perl wrote: >> >> [...] >> > Aren't you in the wrong newsgro

Re: sos!

2005-02-05 Thread jordan2856977
"Dan Perl" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > > Dan Perl wrote: > >> [...] > > Aren't you in the wrong newsgroup? :-) > > Aren't you funny? i think i have solve the problem thank you -- http://mai

Re: sos!

2005-02-05 Thread jordan2856977
"Dan Perl" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > "jordan2856977" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > 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

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

2005-02-05 Thread Ilias Lazaridis
Terry Reedy wrote: "Ilias Lazaridis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] If you ask too much that other people do your searching for you, answers will dry up. I don't ask people to search for me. I ask people for their specific knowledge about specific python language

Re: CGI POST problem was: How to read POSTed data

2005-02-05 Thread Dan Perl
"M.E.Farmer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dan, > I was wondering how you were coming with your project. > I had wondered if i had missed something going the CherryPy route > instead of CGI. Now I see that you have had a bit of a snag , sorry to > hear that. > I a

Re: CGI POST problem was: How to read POSTed data

2005-02-05 Thread M.E.Farmer
Dan Perl wrote: > I am piggybacking on Hakan's original posting because I am addressing the > same group of people (those with good knowledge in the standard web > programming modules), on a related topic. However, my question is > independent of Hakan's. > > I have trouble getting a simple CGI sc

Re: An Ode To My Two Loves

2005-02-05 Thread Luis M. Gonzalez
Jamey, Really, you should try to steer clear from your computer from time to time... Your mental health is more important than python or ruby, don't lose it! -- http://mail.python.org/mailman/listinfo/python-list

RE: bad generator performance

2005-02-05 Thread Robert Brewer
Johannes Ahl mann wrote: > i am in the process of profiling an application and noticed how much > time my depth first generator for walking a tree data structure took. > > i wrote the same thing as a recursive function producing an array, and > this non-generator version is nearly 10 times faster!

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

2005-02-05 Thread Courageous
>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 coincidence >we've never seen or heard Timothy "autocoding" Rue again? Foolish, man! You said his name! It's almost like you said C'thul'hu, ... you ... ah no

Re: CGI POST problem was: How to read POSTed data

2005-02-05 Thread and-google
Dan Perl wrote: > how is a multipart POST request parsed by CGIHTTPServer? It isn't; the input stream containing the multipart/form-data content is passed to the CGI script, which can choose to parse it or not using any code it has to hand - which could be the 'cgi' module, but not necessarily.

ANN: SPE 0.7.2.A IDE with uml, wxGlade and blender support

2005-02-05 Thread http://www.stani.be
Spe is a python IDE with auto-indentation, auto completion, call tips, syntax coloring, uml viewer, syntax highlighting, class explorer, source index, auto todo list, sticky notes, integrated pycrust shell, python file browser, recent file browser, drag&drop, context help, ... Special is its blende

Re: Insane import behaviour and regrtest.py: heeelp

2005-02-05 Thread Nick Coghlan
John J. Lee wrote: The only change I made to regrtest other than the print statements was to add Lib to sys.path, so I pick up modules from CVS instead of the installed 2.4 versions (yeah, I know I should build and install a python2.5 executable from CVS, but I don't see how that's relevant here).

Re: bad generator performance

2005-02-05 Thread Johannes Ahl mann
sorry, forgot to post the profiling info for the recursive helper function. but generator is still FAR slower... 4095/10.0500.0000.1200.120 file.py:135(rek) Johannes -- http://mail.python.org/mailman/listinfo/python-list

Re: empty classes as c structs?

2005-02-05 Thread Nick Coghlan
Steven Bethard wrote: Nick Coghlan wrote: 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 what the current implementation does (although I use 'update' instead of '='). The cod

Re: "pickle" vs. f.write()

2005-02-05 Thread Martin Miller
Marc 'BlackJack' Rintsch wrote: > ... > > I write __repr__() methods similar but I think a bit more readable: > > def __repr__(self): > return "%s(%r, %r, %r, %r)" % (self.__class__.__name__, self.name, > self.age, self.friends, self.comment) > > And it'

bad generator performance

2005-02-05 Thread Johannes Ahl mann
hi, i am in the process of profiling an application and noticed how much time my depth first generator for walking a tree data structure took. i wrote the same thing as a recursive function producing an array, and this non-generator version is nearly 10 times faster! any ideas why this is, what

Re: variable declaration

2005-02-05 Thread Nick Coghlan
Alex Martelli wrote: It's not clear to me what semantics, exactly, x.y := z would be defined to have (assuming := is the syntax sugar for ``rebinding''). Perhaps, by analogy with every other augmented operator, it should be equivalent to: _temp = x.y x.y = type(temp).__irebind__(temp, z) T

Swig-friendly distutils.command.build_ext

2005-02-05 Thread George Sakkis
I'm using a custom extension of the build_ext distutils 'command' that integrates better with SWIG. Specifically, it: 1. Adds '-I' (include) swig option for each directory containing a source file in the given Extension. 2. Determines whether to add the '-c++" option by checking the source file

Re: changing local namespace of a function

2005-02-05 Thread Kent Johnson
Bo Peng wrote: Exec is slow since compiling the string and calls to globals() use a lot of time. The last one is most elegant but __getattr__ and __setattr__ are costly. The 'evil hack' solution is good since accessing x and y takes no additional time. Previous comparison was not completely fa

Re: sos!

2005-02-05 Thread jordan2856977
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > 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

Re: Pickling and inheritance are making me hurt

2005-02-05 Thread Tim Peters
[Kirk Strauser] > I have a module that defines a Search class and a SearchResult class. Try posting a minimal self-contained code sample that fails. > I use these classes by writing other modules that subclass both of them as > needed to interface with particular search engines. > > My problem i

Re: IPython colors in windows

2005-02-05 Thread Gary Bishop
On SourceForge you will find release 1.12 of my Python readline module. If you don't want to hack the colors, there is no reason to upgrade from 1.11 to 1.12. They *should* work the same. But if you'd like to hack the iPython colors this new version makes it possible. In your ipythonrc file add a

Re: Definitive documentation on newstyle classes? (WAS: Pickling and inheritance are making me hurt)

2005-02-05 Thread Daniel Bickett
Bruno Desthuilliers wrote: > Well, the fact is that __[get|set]state__() have nothing to do with new > style classes, but with the Pickle protocol: > http://www.python.org/doc/2.3.4/lib/pickle-inst.html Thank you for pointing that out, but all the same ;) -- Daniel Bickett dbickett at gmail.com

Re: Definitive documentation on newstyle classes? (WAS: Pickling and inheritance are making me hurt)

2005-02-05 Thread Brian van den Broek
Daniel Bickett said unto the world upon 2005-02-05 19:46: I was reading the "Pickling and inheritance are making me hurt" thread, and the latest suggestion (as of this posting) was to do with the __setstate__ and __getstate__ methods. They caught my attention because I hadn't encountered them befor

Re: Definitive documentation on newstyle classes? (WAS: Pickling and inheritance are making me hurt)

2005-02-05 Thread Bruno Desthuilliers
Daniel Bickett a écrit : I was reading the "Pickling and inheritance are making me hurt" thread, and the latest suggestion (as of this posting) was to do with the __setstate__ and __getstate__ methods. They caught my attention because I hadn't encountered them before, and it reminded me that in the

Definitive documentation on newstyle classes? (WAS: Pickling and inheritance are making me hurt)

2005-02-05 Thread Daniel Bickett
I was reading the "Pickling and inheritance are making me hurt" thread, and the latest suggestion (as of this posting) was to do with the __setstate__ and __getstate__ methods. They caught my attention because I hadn't encountered them before, and it reminded me that in the past I've never been abl

Re: Pickling and inheritance are making me hurt

2005-02-05 Thread John J. Lee
Kirk Strauser <[EMAIL PROTECTED]> writes: > I have a module that defines a Search class and a SearchResult class. I use > these classes by writing other modules that subclass both of them as needed > to interface with particular search engines. > > My problem is that Search defines a method (cal

Re: IPython colors in windows

2005-02-05 Thread Gary Bishop
Claudio Grondi <[EMAIL PROTECTED]> wrote: > "Ashot" <[EMAIL PROTECTED]> schrieb im Newsbeitrag > news:[EMAIL PROTECTED] > > whoa, that was quick, looks like it works for me. Thanks a lot! > > It would be nice to be able to set the colors in the prefs file, although > > its possible to edit the pyC

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

2005-02-05 Thread Steven Bethard
Alex Martelli wrote: 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: Computing class variable on demand?

2005-02-05 Thread Steven Bethard
fortepianissimo wrote: Thanks Steve - actually my question was simpler than that. I just wanted to use Daniels' recipe of lazy initialization on objects with __slots__: class Lazy(object): def __init__(self, calculate_function): self._calculate = calculate_function def __get__(self,

Re: How do I convert arithemtic string (like "2+2") to a number?

2005-02-05 Thread Arvid Andersson
On Sat, Feb 05, 2005 at 02:11:07PM -0800, Michael Hartl wrote: > Use the eval function: > > >>> eval("30/(6+9)") > 2 > Thanks, just what I was looking for! -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I enter/receive webpage information?

2005-02-05 Thread John J. Lee
Jorgen Grahn <[EMAIL PROTECTED]> writes: [...] > - subclassed sgmllib.SGMLParser once for each kind of page I expected to > receive. This class knew how to pull the information from a HTML document, > provided it looked as I expected it to. Very tedious work. It can be easier > and safer to

Re: How do I enter/receive webpage information?

2005-02-05 Thread John J. Lee
Jorgen Grahn <[EMAIL PROTECTED]> writes: [...] > I did it this way successfully once ... it's probably the wrong approach in > some ways, but It Works For Me. > > - used httplib.HTTPConnection for the HTTP parts, building my own requests > with headers and all, calling h.send() and h.getrespons

Re: IPython colors in windows

2005-02-05 Thread Claudio Grondi
"Ashot" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] > whoa, that was quick, looks like it works for me. Thanks a lot! > It would be nice to be able to set the colors in the prefs file, although > its possible to edit the pyColorize file as Claudio mentioned. To get the colour

Re: sos!

2005-02-05 Thread Dan Perl
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Dan Perl wrote: >> [...] > Aren't you in the wrong newsgroup? :-) Aren't you funny? -- http://mail.python.org/mailman/listinfo/python-list

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

2005-02-05 Thread Terry Reedy
"Ilias Lazaridis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] If you ask too much that other people do your searching for you, answers will dry up. But here are a couple that you might not find on google anyway, at least not easily. > I want to add metadata to everything with

Insane import behaviour and regrtest.py: heeelp

2005-02-05 Thread John J. Lee
I'm tearing my hair out at what seems like weird import behaviour I'm getting from Python's stdlib test script, regrtest.py (not for the first time: seem to have forgotten the resolution from last time, and the time before, and the time before that, when this damn test script of Python's had me scr

Re: sos!

2005-02-05 Thread [EMAIL PROTECTED]
Dan Perl wrote: > "jordan2856977" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > 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 "py

Re: Computing class variable on demand?

2005-02-05 Thread fortepianissimo
Thanks Steve - actually my question was simpler than that. I just wanted to use Daniels' recipe of lazy initialization on objects with __slots__: class Lazy(object): def __init__(self, calculate_function): self._calculate = calculate_function def __get__(self, obj, _=None):

Re: empty classes as c structs?

2005-02-05 Thread Brian van den Broek
Carlos Ribeiro said unto the world upon 2005-02-05 16:35: On Sat, 05 Feb 2005 15:59:00 -0500, Brian van den Broek <[EMAIL PROTECTED]> wrote: (I'm just a hobbyist, so if this suggestion clashes with some well established use of 'Bag' in CS terminology, well, never mind.) There's already a well know

Re: sos!

2005-02-05 Thread Dan Perl
"jordan2856977" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 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" wr

CGI POST problem was: How to read POSTed data

2005-02-05 Thread Dan Perl
I am piggybacking on Hakan's original posting because I am addressing the same group of people (those with good knowledge in the standard web programming modules), on a related topic. However, my question is independent of Hakan's. I have trouble getting a simple CGI script to work because it

Re: How do I convert arithemtic string (like "2+2") to a number?

2005-02-05 Thread Michael Hartl
Use the eval function: >>> eval("30/(6+9)") 2 Michael -- http://mail.python.org/mailman/listinfo/python-list

Re: pickle/marshal internal format 'life expectancy'/backward compatibility

2005-02-05 Thread Tim Peters
[Philippe C. Martin] > I am looking into using the pickle format to store object/complex data > structures into a smart card as it would make the design of the embedded > application very simple. > > Yet the card might have to stay in the pocket of the customer for a few > years, during which the b

How do I convert arithemtic string (like "2+2") to a number?

2005-02-05 Thread Arvid Andersson
Hello, I need to convert a string to a number, but the string can contain +,-,* and / as well as parenthesis. For example, if I have the string "30/(6+9)" I would like a function that returned the number 2. I actually wrote a java function that did this a couple of years ago, in school, as an e

pickle/marshal internal format 'life expectancy'/backward compatibility

2005-02-05 Thread Philippe C. Martin
Hi, I am looking into using the pickle format to store object/complex data structures into a smart card as it would make the design of the embedded application very simple. Yet the card might have to stay in the pocket of the customer for a few years, during which the back office application res

Re: How to read POSTed data

2005-02-05 Thread Dan Perl
"Håkan Persson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 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.rf

Re: empty classes as c structs?

2005-02-05 Thread Carlos Ribeiro
On Sat, 05 Feb 2005 15:59:00 -0500, Brian van den Broek <[EMAIL PROTECTED]> wrote: > (I'm just a hobbyist, so if this suggestion clashes with some well > established use of 'Bag' in CS terminology, well, never mind.) There's already a well know know use for the 'bag' name, including a recipe in Py

Re: empty classes as c structs?

2005-02-05 Thread Carlos Ribeiro
On Sat, 05 Feb 2005 12:05:13 -0700, Steven Bethard <[EMAIL PROTECTED]> wrote: > The type suggested in this PEP also allows a simple means of > representing hierarchical data that allows attribute-style access:: > > >>> x = Bunch(spam=Bunch(rabbit=1, badger=[2, 3, 4]), ham='neewom') > >>>

Re: changing local namespace of a function

2005-02-05 Thread Bo Peng
Exec is slow since compiling the string and calls to globals() use a lot of time. The last one is most elegant but __getattr__ and __setattr__ are costly. The 'evil hack' solution is good since accessing x and y takes no additional time. Previous comparison was not completely fair since I could

Re: variable declaration

2005-02-05 Thread Arthur
On Sat, 5 Feb 2005 20:02:44 +0100, [EMAIL PROTECTED] (Alex Martelli) wrote: >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 ye

RE: Python Processes for Win32

2005-02-05 Thread Robert Brewer
[EMAIL PROTECTED] wrote: > 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

Re: changing local namespace of a function

2005-02-05 Thread Bo Peng
Kent Johnson wrote: You can part way there using keyword arguments. You just have to use dictionary syntax for changing values in the dictionary: >>> def f(d, x=None, y=None): ... d['z'] = x + y ... >>> a = {'x':1, 'y':2} >>> b = {'x':3, 'y':3} >>> >>> f(a, **a) >>> a {'y': 2, 'x': 1, '

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'

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

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

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

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

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

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

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

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

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

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

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

  1   2   >