Re: python function for retrieving key and encryption

2009-07-26 Thread jayshree
On Jul 23, 5:48 pm, Piet van Oostrum wrote: > > jayshree (j) wrote: > >j> On Jul 21, 8:59 pm, Piet van Oostrum wrote: > >>> The recipient_public_key.pem file is the public key of the recipient > >>> which means the person that is going to receive the encrypted message. > >>> You should get i

Re: Distinguishing active generators from exhausted ones

2009-07-26 Thread Steven D'Aprano
On Mon, 27 Jul 2009 02:02:19 -0400, Terry Reedy wrote: > Steven D'Aprano wrote: >> On Sun, 26 Jul 2009 20:10:00 -0400, Terry Reedy wrote: >> >>> Michal Kwiatkowski wrote: >>> The thing is I don't need the next item. I need to know if the generator has stopped without invoking it. >>> Wr

Re: missing 'xor' Boolean operator

2009-07-26 Thread Terry Reedy
greg wrote: Terry Reedy wrote: In Math and Python, a Although Python extends the chaining principle to !=, this is somewhat questionable, because a < b and b < c implies a < c, but a != b and b != c does not imply a != c. I'm not sure I've ever seen a mathematician write a != b != c, but if I

Re: Distinguishing active generators from exhausted ones

2009-07-26 Thread Terry Reedy
Steven D'Aprano wrote: On Sun, 26 Jul 2009 20:10:00 -0400, Terry Reedy wrote: Michal Kwiatkowski wrote: The thing is I don't need the next item. I need to know if the generator has stopped without invoking it. Write a one-ahead iterator class, which I have posted before, that sets .exhausted

Re: len() should always return something

2009-07-26 Thread drednot57
To the best of my recollection, the len() function only applies to container objects; i. e. tuples, lists, strings, etc. an integer object is not a container, thus one receives an error when sending an int as an argument for len(). -- http://mail.python.org/mailman/listinfo/python-list

Re: How to comment constant values?

2009-07-26 Thread Robert Kern
On 2009-07-26 18:23, Steven D'Aprano wrote: On Mon, 27 Jul 2009 00:47:08 +0200, Diez B. Roggisch wrote: Only modules, classes, and functions/methods can have docstrings associated with them. For anything else, you have to use comments; or you can mention them in the docstrings of related things

Re: PyQt GUI

2009-07-26 Thread Robert Kern
On 2009-07-26 07:04, Helvin wrote: C:\Qt\VTKbin7\Wrapping\Python>python setup.py install Traceback (most recent call last): File "setup.py", line 138, in raise "ERROR: Must specify BUILD_TYPE= on command line." TypeError: exceptions must be classes or instances, not str Is it just a sm

Re: Distinguishing active generators from exhausted ones

2009-07-26 Thread Steven D'Aprano
On Sun, 26 Jul 2009 20:10:00 -0400, Terry Reedy wrote: > Michal Kwiatkowski wrote: > >> The thing is I don't need the next item. I need to know if the >> generator has stopped without invoking it. > > Write a one-ahead iterator class, which I have posted before, that sets > .exhausted to True wh

Re: Distinguishing active generators from exhausted ones

2009-07-26 Thread greg
Michal Kwiatkowski wrote: The first generator isn't finished, it yielded 1 and None. Second one is exhausted after yielding a single value (1). The problem is that, under Python 2.4 or 2.3 both invocations will generate the same trace output. This seems to be a deficiency in the trace mechanis

Re: missing 'xor' Boolean operator

2009-07-26 Thread greg
Terry Reedy wrote: In Math and Python, a Although Python extends the chaining principle to !=, this is somewhat questionable, because a < b and b < c implies a < c, but a != b and b != c does not imply a != c. I'm not sure I've ever seen a mathematician write a != b != c, but if I did, I would

Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler

2009-07-26 Thread Bearophile
William Dode': > I updated the script (python, c and java) with your unrolled version > + somes litle thinks. [...] > c 1.85s > gcj 2.15s > java 2.8s > python2.5 + psyco 3.1s > unladen-2009Q2 145s (2m45) > python2.5 254s (4m14s) > python3.1 300s (5m) > ironpython1.1.1 680s (11m20) Sorry for being

RE: missing 'xor' Boolean operator

2009-07-26 Thread Delaney, Timothy (Tim)
Mark Dickinson wrote: >> Since the 'and' and 'or' already return objects (and objects >> evaluate to true or false), then 'xor' should behave likewise, IMO. >> I expect that would be the case if it were ever added to the >> language. > > I'm not so sure. Did you ever wonder why the any() and al

Re: Mutable Strings - Any libraries that offer this?

2009-07-26 Thread Jack Diederich
On Mon, Jul 20, 2009 at 5:57 AM, casebash wrote: > Hi, > > I have searched this list and found out that Python doesn't have a > mutable string class (it had an inefficient one, but this was removed > in 3.0). Are there any libraries outside the core that offer this? It depends on how mutable you w

Re: Mutable Strings - Any libraries that offer this?

2009-07-26 Thread Neil Hodgson
Mark Lawrence: > If my sleuthing is correct the problem is with these lines > > ilow *= self->itemSize; > ihigh *= self->itemSize; > > in GapBuffer_slice being computed before ilow and ihigh are compared to > anything. This particular bug was because ihigh is the maximum 32 bit integer 21474

Re: Distinguishing active generators from exhausted ones

2009-07-26 Thread Terry Reedy
Michal Kwiatkowski wrote: The thing is I don't need the next item. I need to know if the generator has stopped without invoking it. Write a one-ahead iterator class, which I have posted before, that sets .exhausted to True when next fails. tjr -- http://mail.python.org/mailman/listinfo/pyt

Re: Distinguishing active generators from exhausted ones

2009-07-26 Thread Aahz
In article <2a408da6-af57-45d0-a75f-4cbe384bb...@s15g2000yqs.googlegroups.com>, Michal Kwiatkowski wrote: >On Jul 25, 10:00=A0pm, Jason Tackaberry wrote: >> On Sat, 2009-07-25 at 11:30 -0700, Michal Kwiatkowski wrote: >>> >>> Is there a way to tell if a generator has been exhausted using pure >>

Re: python fast HTML data extraction library

2009-07-26 Thread Filip
On Jul 23, 3:53 am, Paul McGuire wrote: > # You should use raw string literals throughout, as in: > # blah_re = re.compile(r'sljdflsflds') > # (note the leading r before the string literal).  raw string > literals > # really help keep your re expressions clean, so that you don't ever > # have to d

Re: If Scheme is so good why MIT drops it?

2009-07-26 Thread Andrew Reilly
On Sun, 26 Jul 2009 09:31:06 -0400, Raffael Cavallaro wrote: > On 2009-07-26 09:16:39 -0400, a...@pythoncraft.com (Aahz) said: > >> There are plenty of expert C++ >> programmers who switched to Python; > > "plenty" is an absolute term, not a relative term. I sincerely doubt > that the majority o

Re: How to comment constant values?

2009-07-26 Thread Steven D'Aprano
On Mon, 27 Jul 2009 00:47:08 +0200, Diez B. Roggisch wrote: >> Only modules, classes, and functions/methods can have docstrings >> associated with them. >> For anything else, you have to use comments; or you can mention them in >> the docstrings of related things. > > While this is technically tr

Re: How to comment constant values?

2009-07-26 Thread Steven D'Aprano
On Sun, 26 Jul 2009 15:42:22 -0700, Bearophile wrote: > Chris Rebert: >> Only modules, classes, and functions/methods can have docstrings >> associated with them. >> For anything else, you have to use comments; or you can mention them in >> the docstrings of related things. > > What about adding

Re: Help understanding the decisions *behind* python? - immutable objects

2009-07-26 Thread Steven D'Aprano
On Sun, 26 Jul 2009 11:24:48 -0700, John Nagle wrote: > An interesting issue is Python objects, which are always mutable. > A "dict" of Python objects is allowed, but doesn't consider the contents > of the objects, just their identity (address). Only built-in types are > immutable; one cannot

Re: Can't get UDP example to work

2009-07-26 Thread Steven D'Aprano
On Sun, 26 Jul 2009 12:40:39 -0700, Paul Barry wrote: > On Jul 26, 12:53 pm, Roy Smith wrote: >> In article >> <148abf0f-c9e4-4156-8f16-e4e5615d3...@s6g2000vbp.googlegroups.com>, >>  Paul Barry wrote: >> >> > host = '127.0.0.1'           # Bind to all interfaces >> >> This threw me off the track

Re: Globalize all variables in function without knowing names.

2009-07-26 Thread Steven D'Aprano
On Sun, 26 Jul 2009 15:07:08 -0700, Tom wrote: > Ah, thanks for that Dennis. I have a system already figured out where > the user manually pre-enters all the variables into a .py file, which > obviously isn't very efficient. The language isn't going to be used much > except by me, so I suppose I'l

Re: How to comment constant values?

2009-07-26 Thread Diez B. Roggisch
Chris Rebert schrieb: On Sun, Jul 26, 2009 at 2:49 PM, Erwin Mueller wrote: Hello, I'm new to Python (using it for two months) and I wonder how can I comment the const. values with the doc-strings. I.e. if I have code: FRACTION_MIN = 1 FRACTION_MAX = 10 class Fraction(collections.MutableSeque

Re: Error in compiling Python on OS X

2009-07-26 Thread Diez B. Roggisch
Kevin schrieb: I am trying to compile Python 2.6.2 on Mac OS X 10.5.7. I have Xcode 3.1.3 installed. The error I got is below. $ ./configure --prefix=/Users/me/python Use a framework-build. checking for --with-universal-archs... 32-bit checking MACHDEP... darwin checking EXTRAPLATDIR... $(

Re: How to comment constant values?

2009-07-26 Thread Bearophile
Chris Rebert: > Only modules, classes, and functions/methods can have docstrings > associated with them. > For anything else, you have to use comments; or you can mention them > in the docstrings of related things. What about adding docstrings to other Python things, especially to variables? Bye,

Re: If Scheme is so good why MIT drops it?

2009-07-26 Thread Rhodri James
On Sun, 26 Jul 2009 14:31:06 +0100, Raffael Cavallaro wrote: On 2009-07-26 09:16:39 -0400, a...@pythoncraft.com (Aahz) said: There are plenty of expert C++ programmers who switched to Python; "plenty" is an absolute term, not a relative term. I sincerely doubt that the majority of pytho

Error in compiling Python on OS X

2009-07-26 Thread Kevin
I am trying to compile Python 2.6.2 on Mac OS X 10.5.7. I have Xcode 3.1.3 installed. The error I got is below. $ ./configure --prefix=/Users/me/python checking for --with-universal-archs... 32-bit checking MACHDEP... darwin checking EXTRAPLATDIR... $(PLATMACDIRS) checking machine type as report

Re: Globalize all variables in function without knowing names.

2009-07-26 Thread Tom
Ah, thanks for that Dennis. I have a system already figured out where the user manually pre-enters all the variables into a .py file, which obviously isn't very efficient. The language isn't going to be used much except by me, so I suppose I'll just work with that until I look more into dictionarie

Re: How to comment constant values?

2009-07-26 Thread Chris Rebert
On Sun, Jul 26, 2009 at 2:49 PM, Erwin Mueller wrote: > Hello, I'm new to Python (using it for two months) and I wonder how can I > comment the const. values with the doc-strings. I.e. if I have code: > >>FRACTION_MIN = 1 >>FRACTION_MAX = 10 >> >>class Fraction(collections.MutableSequence): >>    '

How to comment constant values?

2009-07-26 Thread Erwin Mueller
Hello, I'm new to Python (using it for two months) and I wonder how can I comment the const. values with the doc-strings. I.e. if I have code: >FRACTION_MIN = 1 >FRACTION_MAX = 10 > >class Fraction(collections.MutableSequence): >'''Model a fraction with denominators. > >It contains one or

Re: If Scheme is so good why MIT drops it?

2009-07-26 Thread Raffael Cavallaro
On 2009-07-26 17:04:23 -0400, Roy Smith said: One needs to have a very highly developed sense of theoretical purity to look down their noses at the language that drives one of the highest volume web sites on the planet. It's nothing to do with theoretical purity and everything to do with pra

Re: C-API, tp_dictoffset vs tp_members

2009-07-26 Thread Martin v. Löwis
> I have a predefined set of members, some of which are optional. Having optional fields is also a good reason. >>> What is the use of T_OBJECT_EX vs T_OBJECT in PyMemberDef then? >> Right - this works for optional objects. However, it can't possibly >> work for any of the other fields. >

Re: invoke method on many instances

2009-07-26 Thread Gabriel Genellina
En Sun, 26 Jul 2009 12:44:02 -0300, Aahz escribió: In article , Gabriel Genellina wrote: En Thu, 23 Jul 2009 21:27:35 -0300, Aahz escribió: In article , Gabriel Genellina wrote: NLMPI What? IHNFI What? Abbreviations are fine, but if someone asks you about one, it would be nice to

Re: If Scheme is so good why MIT drops it?

2009-07-26 Thread Roy Smith
In article , Raffael Cavallaro wrote: > php is clearly a lesser language than python. I'm as much of a Python bigot as anybody. Likewise, I put down php for all the sorts of theoretical reasons people have been putting it down. Not to mention that it looks like Perl, which is enough to ma

Re: Removing newlines from string on windows (without replacing)

2009-07-26 Thread Tom
> (Even if it so happens sauce > will only ever have LFs at the end, it's still better to use the > method that is closest to your intended meaning.) Oh, you're right. I'll change that now. I suppose removing all endlines will be better, incase, somehow, endlines in the middle of the line arrises.

Re: If Scheme is so good why MIT drops it?

2009-07-26 Thread MRAB
David Robinow wrote: This doesn't mean they're on the same level - in fact, if you read carefully you'll see my original post said as much: python attracted average programmers; php attracted mediocre programmers and even some non-programmers, which means that php is clearly a lesser language tha

Re: Can't get UDP example to work

2009-07-26 Thread Roy Smith
In article <2f578124-1ae3-45a5-a0c9-b8b05c0b5...@p23g2000vbl.googlegroups.com>, Paul Barry wrote: > In this case, I think he's trying to illustrate how the UDP example > compares to the TCP example from the previous section, which is why he > choose to keep the methods the same. I suppose,

Globalize all variables in function without knowing names.

2009-07-26 Thread Tom
Does anyknow know how to do this? The reason I'm asking is because I'm trying to make a mini-programming language for fun, and need to work with variables. The user types 'set NAME "DATA" ' or whatever else the variable is going to be called/contain. I have: def variablework(varname, varset):

Re: Can't get UDP example to work

2009-07-26 Thread Paul Barry
On Jul 26, 11:07 am, MRAB wrote: > Paul Barry wrote: > > I'm trying to get one of the examples from Foundation of Python > > Network Programming to work.  Specifically this is the UDP example > > from Ch 3.  First there is the server: > > > #!/usr/bin/env python > > # UDP Echo Server - Chapter 3 -

Re: Can't get UDP example to work

2009-07-26 Thread Paul Barry
On Jul 26, 12:53 pm, Roy Smith wrote: > In article > <148abf0f-c9e4-4156-8f16-e4e5615d3...@s6g2000vbp.googlegroups.com>, >  Paul Barry wrote: > > > host = '127.0.0.1'           # Bind to all interfaces > > This threw me off the track for a little while.  The comment is wrong!   > You're not bindi

Re: C-API, tp_dictoffset vs tp_members

2009-07-26 Thread Ulrich Eckhardt
"Martin v. Löwis" wrote: I have a predefined set of members, some of which are optional. >>> Having optional fields is also a good reason. >> >> What is the use of T_OBJECT_EX vs T_OBJECT in PyMemberDef then? > > Right - this works for optional objects. However, it can't possibly > work for

Looking for a dream language: sounds like Python to me.

2009-07-26 Thread Dotan Cohen
Referring to this article: http://math-blog.com/2009/07/20/complex-algorithm-research-and-development-harder-than-many-think/ The author, who is specifically looking for math-related functions, writes: """ The dream algorithm R&D tool would be similar to Matlab or Mathematica but could be compiled

Re: pyc files not automatically compiled on import

2009-07-26 Thread Baz Walter
Peter Otten wrote: You did not set the PYTHONDONTWRITEBYTECODE environment variable in a former life, or did you? thanks peter no i didn't, but i've just discovered a script in /etc/profile.d that did. now i'll have to try to find out how that script got in there :-| -- http://mail.python.o

Re: If Scheme is so good why MIT drops it?

2009-07-26 Thread David Robinow
> This doesn't mean they're on the same level - in fact, if you read carefully > you'll see my original post said as much: python attracted average > programmers; php attracted mediocre programmers and even some > non-programmers, which means that php is clearly a lesser language than > python. I'

Re: Pep 342 (val = yield MyGenerator(foo)), synchronous os.system() that doesn't block gui event loops

2009-07-26 Thread Ville M. Vainio
Apologies for the long subject line, here it is again: "Pep 342 (val = yield MyGenerator(foo)), synchronous os.system() that doesn't block gui event loops" On Jul 21, 7:48 pm, John Nagle wrote: > > The idea: > > > To run functions that execute a series of system commands without > > blocking th

Re: Help understanding the decisions *behind* python? - immutable objects

2009-07-26 Thread John Nagle
Beni Cherniavsky wrote: On Jul 22, 9:36 am, Hendrik van Rooyen wrote: On Tuesday 21 July 2009 15:49:59 Inky 788 wrote: My guess is that it was probably for optimization reasons long ago. I've never heard a *good* reason why Python needs both. The good reason is the immutability, which lets y

Re: Pep 342 (val = yield MyGenerator(foo)), synchronous os.system() that doesn't block gui event loops

2009-07-26 Thread Ville M. Vainio
On Jul 23, 11:29 pm, Nick Craig-Wood wrote: > >  The syntax would be something like: > > >  def work(): > > >    showstatus("building") > >    r = yield runshell("make") > >    showstatus("installing") > >    r = yield runshell("make install") > >    showstatus("Success") > > >  mygui.startwork(w

Itext for Python

2009-07-26 Thread Santhosh Kumar
Hi all, One of my cousin suggested me to do a IText PDF converter for python. Actually I heard that there is no separate IText converter either we have to go for jython or GCJ with wrapper. Instead of wrapping, my plan is to create a separate module with Python and I am thinking of doing

Re: C-API, tp_dictoffset vs tp_members

2009-07-26 Thread Martin v. Löwis
>>> I have a predefined set of members, some of which are optional. >> Having optional fields is also a good reason. > > What is the use of T_OBJECT_EX vs T_OBJECT in PyMemberDef then? Right - this works for optional objects. However, it can't possibly work for any of the other fields. > I woul

Re: Removing newlines from string on windows (without replacing)

2009-07-26 Thread Aahz
In article , Tom wrote: > >I have an annoying problem. While I mainly use Linux when I distribute >this program to friends and on the internet, it'll get used on Windows. >So, I tested my python program on my Windows Vista dual boot, running >the same version of python (2.6) as my Linux, and got

Re: Removing newlines from string on windows (without replacing)

2009-07-26 Thread John Yeung
On Jul 26, 1:13 pm, Tom wrote: > The thing that was messing it up was that the endlines are handled > differently on each each OS, so I changed the code to strip the > endlines to be: > >     if os.name == "nt": >         s = sauce.rstrip("\r\n") >     else: >         s = sauce.replace("\n", "")

Re: How do I generate dia diagrams from python source code?

2009-07-26 Thread Qauzzix
On Jul 25, 8:31 am, "Gabriel Genellina" wrote: > En Fri, 24 Jul 2009 17:52:47 -0300, Qauzzix escribió: > > > Since I have been usingdiato make my UML diagrams. I also found an > > util named dia2code that generates python code fromdiadiagram. Now > > that I have that option I really want to find

Re: Removing newlines from string on windows (without replacing)

2009-07-26 Thread Tom
Sorry for not providing enough information - and Rhodri, for sending my second message I used the GMX webmail client rather than my usual Linux client as I was testing it on windows. That must have screwed it up, I need to download Thunderbird on Mozzila. The thing that was messing it up was that

Re: pyc files not automatically compiled on import

2009-07-26 Thread Peter Otten
Baz Walter wrote: > i thought that python automatically compiled pyc files after a module is > successfully imported. what could prevent this happening? > > > Python 2.6.1 (r261:67515, Apr 12 2009, 03:51:25) > [GCC 4.3.2] on linux2 > Type "help", "copyright", "credits" or "license" for more info

Re: Can't get UDP example to work

2009-07-26 Thread Roy Smith
In article <148abf0f-c9e4-4156-8f16-e4e5615d3...@s6g2000vbp.googlegroups.com>, Paul Barry wrote: > host = '127.0.0.1' # Bind to all interfaces This threw me off the track for a little while. The comment is wrong! You're not binding to all interfaces, you're binding specifically to

Re: pyc files not automatically compiled on import

2009-07-26 Thread Fuzzyman
On Jul 26, 5:22 pm, Baz Walter wrote: > hello > > i thought that python automatically compiled pyc files after a module is > successfully imported. what could prevent this happening? > > Python 2.6.1 (r261:67515, Apr 12 2009, 03:51:25) > [GCC 4.3.2] on linux2 > Type "help", "copyright", "credits"

pyc files not automatically compiled on import

2009-07-26 Thread Baz Walter
hello i thought that python automatically compiled pyc files after a module is successfully imported. what could prevent this happening? Python 2.6.1 (r261:67515, Apr 12 2009, 03:51:25) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os

Re: Why doesn't `from pkg import mod' work after `del pkg.mod'?

2009-07-26 Thread Piet van Oostrum
> ryles (r) wrote: >r> On Jul 25, 8:57 am, Piet van Oostrum wrote: >>> > ryles (r) wrote: >>> >r> According tohttp://www.python.org/doc/essays/packages.html: >>> >r> "The import statement first tests whether the item is defined in the >>> >r> package; if not, it assumes it is a module a

Re: Override a method but inherit the docstring

2009-07-26 Thread Aahz
In article <056f629b-aa63-458a-ae16-ac40a759e...@h11g2000yqb.googlegroups.com>, Shai wrote: > >class DocInherit(object): >""" >Docstring inheriting method descriptor > >The class itself is also used as a decorator >""" Nice! Maybe stick this on the Cookbook? -- Aahz (a...@pytho

Re: python fast HTML data extraction library

2009-07-26 Thread John Machin
On Jul 23, 11:53 am, Paul McGuire wrote: > On Jul 22, 5:43 pm, Filip wrote: > > # Needs re.IGNORECASE, and can have tag attributes, such as CLEAR="ALL"> > line_break_re = re.compile('', re.UNICODE) Just in case somebody actually uses valid XHTML :-) it might be a good idea to allow for > # w

Re: Cannot Get Form To Work

2009-07-26 Thread Victor Subervi
Oops. My bad. I did in fact have this line of code before calls to form: form = cgi.FieldStorage() I changed the except command from "pass" to "print sys.exc_info()" as per your suggestion. Still, however, the form just renews itself without offering any information whatsoever. You can see this h

Re: invoke method on many instances

2009-07-26 Thread Aahz
In article , Gabriel Genellina wrote: >En Thu, 23 Jul 2009 21:27:35 -0300, Aahz escribió: >> In article , >> Gabriel Genellina wrote: >>> >>> NLMPI >> >> What? > >IHNFI What? Abbreviations are fine, but if someone asks you about one, it would be nice to just expand it instead of replying with

Re: 'Registry' or 'Preference' settings in Mac Python

2009-07-26 Thread Petite Abeille
On Jul 26, 2009, at 5:09 PM, Robert Avery wrote: In Windows, the Registry serves this purpose. Is there something similar for Mac? http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/Reference/Reference.html http://developer.apple.com/documentati

Re: cgi.fieldstorage()

2009-07-26 Thread Diez B. Roggisch
gert schrieb: On Jul 25, 2:33 am, "Diez B. Roggisch" wrote: gert schrieb: On Jul 24, 7:32 pm, "Diez B. Roggisch" wrote: gert schrieb: this is a non standard way to store multi part post data on disk def application(environ, response): with open('/usr/httpd/var/wsgiTemp','w') as f:

'Registry' or 'Preference' settings in Mac Python

2009-07-26 Thread Robert Avery
Is there any way for me to save some sort of global preference for python that I can read/write at runtime that doesn't involve me explicitly creating a file? It may create a file underneath, but I don't want some path hard coded to my routine. In Windows, the Registry serves this purpose. Is th

Re: Can't get UDP example to work

2009-07-26 Thread MRAB
Paul Barry wrote: I'm trying to get one of the examples from Foundation of Python Network Programming to work. Specifically this is the UDP example from Ch 3. First there is the server: #!/usr/bin/env python # UDP Echo Server - Chapter 3 - udpechoserver.py import socket, traceback, time host

Can't get UDP example to work

2009-07-26 Thread Paul Barry
I'm trying to get one of the examples from Foundation of Python Network Programming to work. Specifically this is the UDP example from Ch 3. First there is the server: #!/usr/bin/env python # UDP Echo Server - Chapter 3 - udpechoserver.py import socket, traceback, time host = '127.0.0.1'

Re: If Scheme is so good why MIT drops it?

2009-07-26 Thread Raffael Cavallaro
On 2009-07-26 09:16:39 -0400, a...@pythoncraft.com (Aahz) said: There are plenty of expert C++ programmers who switched to Python; "plenty" is an absolute term, not a relative term. I sincerely doubt that the majority of python users were formerly *expert* C++ programmers. your thesis onl

Re: If Scheme is so good why MIT drops it?

2009-07-26 Thread Aahz
In article , Raffael Cavallaro wrote: >On 2009-07-25 00:55:26 -0400, Carl Banks said: >> >> But please don't put it on the same level as PHP. Their situations >> have almost nothing in common. > >Their situations have much in common; Python attracted programmers away >from (for example) C++, b

Re: PyQt GUI

2009-07-26 Thread Helvin
On Jul 24, 5:03 am, Robert Kern wrote: > On 2009-07-23 03:55, Helvin wrote: > > > I believe I now have vtkpython.exe. However, my 'import vtk' statement > > in my python code is not working. The error says something like "no > > module named vtk". > > Where do I find modules for vtk inpyqt? Do the

Re: how can a child thread notify a parent thread its status?

2009-07-26 Thread Piet van Oostrum
> MRAB (M) wrote: >M> scriptlear...@gmail.com wrote: >>> I decided to go with one big log file, which will be shared by all >>> threads (child and parent). A log message Queue is used to store all >>> log entries, and a customized logger thread will get log entries from >>> the Queue. >>> >

Re: Mutable Strings - Any libraries that offer this?

2009-07-26 Thread Mark Lawrence
Neil Hodgson wrote: casebash: I have searched this list and found out that Python doesn't have a mutable string class (it had an inefficient one, but this was removed in 3.0). Are there any libraries outside the core that offer this? I wrote a gap buffer implementation for Python 2.5 allow

Re: I am trying to compile python 2.6.2 on my Mac

2009-07-26 Thread Diez B. Roggisch
Jessica Smith schrieb: Chris thanks!! other members: I read this: - http://chrismiles.livejournal.com/25648.html I did this: - install mac ports - port install readline - vi setup.py def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list

Re: ANN: psyco V2

2009-07-26 Thread William Dode
On 24-07-2009, Christian Tismer wrote: > On 7/24/09 1:04 AM, William Dode wrote: >> On 23-07-2009, Christian Tismer wrote: > ... > >>> Wasn't the project plan saying the opposite, borrowing >>> some ideas from psyco? :-) >>> http://code.google.com/p/unladen-swallow/wiki/ProjectPlan >> >> How do you

Re: len() should always return something

2009-07-26 Thread Erik Max Francis
Steven D'Aprano wrote: I'm curious what those applications are, because regular multiplication behaves differently depending on whether you have a 1x1 matrix or a scalar: [[2]]*[[1, 2, 3], [2, 3, 4]] is not defined 2*[[1, 2, 3], [2, 3, 4]] = [[2, 4, 6], [2, 6, 8]] I'm curious as to what thes

Re: Removing newlines from string on windows (without replacing)

2009-07-26 Thread Ulrich Eckhardt
Tom wrote: > s = sauce.replace("\n", "") > > Sauce is a string, read from a file, that I need to remove newlines > from. This code works fine in Linux, but not in Windows. rstrip("\n") > won't work for me, so anybody know how to get this working on Windows? I'm pretty sure this works regardless o

Re: multiprocessing and __main__

2009-07-26 Thread iu2
On Jul 26, 8:52 am, is un wrote: > Hi, > > Trying the multiprocessing module for the first time, I spent quite a > bit on making this code run: > > from multiprocessing import Process > import time > > def my_process(): >     i = 0 >     while 1: >         print i >         i += 1 >         time.s

Re: C-API, tp_dictoffset vs tp_members

2009-07-26 Thread Ulrich Eckhardt
"Martin v. Löwis" wrote: >> I have a predefined set of members, some of which are optional. > > Having optional fields is also a good reason. What is the use of T_OBJECT_EX vs T_OBJECT in PyMemberDef then? I would have though that the former describes an optional field, because the behaviour of

Re: len() should always return something

2009-07-26 Thread Steven D'Aprano
On Sat, 25 Jul 2009 16:21:39 -0700, Erik Max Francis wrote: > Steven D'Aprano wrote: >> But it's not "practically every function". It's hardly any function at >> all -- in my code, I don't think I've ever wanted this behavior. I >> would consider it an error for function(42) and function([42]) to

Re: code debugging

2009-07-26 Thread Gabriel Genellina
En Sun, 26 Jul 2009 03:33:27 -0300, golu escribió: i want to save pages in a directory and i m using the urls to get filenames. The program gets stuck in the saving step.can u suggest me a way to save a page e.g google.com as a file google.html You may use str.translate to replace/remove al

Re: strange error when trying to log something

2009-07-26 Thread Peter Otten
Aahz wrote: > In article , > Peter Otten <__pete...@web.de> wrote: >> >>I have a hunch that you are triggering a reload() somewhere. Example: >> >>Python 2.6.2 (release26-maint, Apr 19 2009, 01:58:18) >>[GCC 4.3.3] on linux2 >>Type "help", "copyright", "credits" or "license" for more information.

Re: I am trying to compile python 2.6.2 on my Mac

2009-07-26 Thread Jessica Smith
Chris thanks!! other members: I read this: - http://chrismiles.livejournal.com/25648.html I did this: - install mac ports - port install readline - vi setup.py def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_di

Re: Distinguishing active generators from exhausted ones

2009-07-26 Thread Michal Kwiatkowski
On Jul 26, 1:10 am, Ben Finney wrote: > Michal Kwiatkowski writes: > > I may be missing something obvious here. Is there a better way to tell > > if a given generator object is still active or not? > >     foo = the_generator_object >     try: >         do_interesting_thing_that_needs(foo.next())

Re: I am trying to compile python 2.6.2 on my Mac

2009-07-26 Thread Chris Rebert
On Sun, Jul 26, 2009 at 1:12 AM, Jessica R Smith wrote: > Hello, > I am trying to compile Python 2.6.2 on my Mac which has os/x 10.5.7 > > I downloaded python 2.6.2 from here: >  - http://www.python.org/ftp/python/2.6.2/Python-2.6.2.tar.bz2 > > I unpacked it. > > I ran these shell commands: >  - ./

Re: Failed Regression Test: What socket.gethostname() is supposed to return?

2009-07-26 Thread Nobody
On Sun, 26 Jul 2009 08:30:30 +1000, Lie Ryan wrote: > since on my system socket.gethostname() returns 'lieryan', and since > socket.gethostbyname('lieryan') does not resolve to anything; the test > becomes an error. > > My system is Gentoo, but I think this also happened on Ubuntu (still on > thi

I am trying to compile python 2.6.2 on my Mac

2009-07-26 Thread Jessica R Smith
Hello, I am trying to compile Python 2.6.2 on my Mac which has os/x 10.5.7 I downloaded python 2.6.2 from here: - http://www.python.org/ftp/python/2.6.2/Python-2.6.2.tar.bz2 I unpacked it. I ran these shell commands: - ./configure --prefix=/pt/p - make Near the end of the make output I se

Re: multiprocessing and __main__

2009-07-26 Thread Gabriel Genellina
En Sun, 26 Jul 2009 02:52:36 -0300, is un escribió: Trying the multiprocessing module for the first time, I spent quite a bit on making this code run: [...] The result was not what I expected, it seems like the process restarts all the time, and the message 'Process started' keeps getting pri

Re: C-API, tp_dictoffset vs tp_members

2009-07-26 Thread Martin v. Löwis
> When would I use PyObject_SetAttrString/tp_dictoffset instead of tp_members? When I have a variable list of attributes, and cannot statically know what those attributes might be. > I have a predefined set of members, some of which are optional. Having optional fields is also a good reason. >

Re: non-owning references?

2009-07-26 Thread Emmanuel Surleau
On Friday 24 July 2009 17:14:06 you wrote: > Hrvoje Niksic writes: > > The term "variable" is used in the Python language reference and > > elsewhere > > Yes. It should also be abundantly clear from the constant stream of > confused newbies on this point that its usage of that term is different >

Re: Distinguishing active generators from exhausted ones

2009-07-26 Thread Hendrik van Rooyen
On Saturday 25 July 2009 20:30:54 Michal Kwiatkowski wrote: > Hi, > > Is there a way to tell if a generator has been exhausted using pure > Python code? I've looked at CPython sources and it seems that > something like "active"/"exhausted" attribute on genobject is missing > from the API. For the t

Re: len() should always return something

2009-07-26 Thread Emmanuel Surleau
On Sunday 26 July 2009 00:42:26 Marcus Wanner wrote: > On 7/25/2009 10:08 AM, Piet van Oostrum wrote: > >> Steven D'Aprano (SD) wrote: > >> > >> SD> Ambiguity essentially boils down to being unable to reasonably > >> predict SD> the expectation of the coder. I say "reasonably", because if > >>

web page retrieve problems

2009-07-26 Thread golu
the following function retrieves pages from the web and saves them in a specified dir. i want to extract the respective filenames from the urls e.g the page code.google.com shud be saved as code-google.htm or something similar. can u suggest me a way to do it def retrieve_url(self,url): ""