multiprocessing and __main__

2009-07-26 Thread is un
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.sleep(0.5) p = Process(target=my_process, args=())

Re: MySQLdb for Python 3.1 getting close?

2009-07-26 Thread John Nagle
(This is actually a repost; outgoing netnews server was down for a while.) John Nagle wrote: Is MySQLdb available for Python 3.1 yet? http://sourceforge.net/projects/mysql-python/ says the last supported Python version is 2.5. Any progress in sight? John Nagle --

Re: multiprocessing and __main__

2009-07-26 Thread is un
Me again, fix a type in my question: So my question is what actually happens when I call p.start()? Is the *entire* file reloaded under a different module name? Thanks iu2 -- http://mail.python.org/mailman/listinfo/python-list

Re: non-owning references?

2009-07-26 Thread John Nagle
Peter Otten wrote: Utpal Sarkar wrote: Is there a way I can tell a variable that the object it is pointing too is not owned by it, in the sense that if it is the only reference to the object it can be garbage collected? http://docs.python.org/library/weakref.html Yes. Weak references

Re: code debugging

2009-07-26 Thread Chris Rebert
On Sat, Jul 25, 2009 at 11:23 PM, golubhardwajjaye...@gmail.com wrote: here is a code which crawls links sent to it. theres some problem with the retrieve_url function ,plz help me out in debugging the fuction retrive_url. This function retrives pages and saves them in file Please specify

code debugging

2009-07-26 Thread golu
here is a code which crawls links sent to it. theres some problem with the retrieve_url function ,plz help me out in debugging the fuction retrive_url. This function retrives pages and saves them in file #TODO:Visited dict grows in size it needs to be handled smartly #Moreover server program needs

Re: code debugging

2009-07-26 Thread golu
On Jul 26, 11:28 am, Chris Rebert c...@rebertia.com wrote: On Sat, Jul 25, 2009 at 11:23 PM, golubhardwajjaye...@gmail.com wrote: here is a code which crawls links sent to it. theres some problem with the retrieve_url function ,plz help me out in debugging the fuction retrive_url. This

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

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 st...@remove-this-cybersource.com.au (SD) wrote: SD Ambiguity essentially boils down to being unable to reasonably predict SD the expectation of the coder. I say reasonably,

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

Re: non-owning references?

2009-07-26 Thread Emmanuel Surleau
On Friday 24 July 2009 17:14:06 you wrote: Hrvoje Niksic hnik...@xemacs.org 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

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: multiprocessing and __main__

2009-07-26 Thread Gabriel Genellina
En Sun, 26 Jul 2009 02:52:36 -0300, is un israel.unter...@gmail.com 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

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

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 this

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 Smithjessica.1980.sm...@gmail.com 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

Re: Distinguishing active generators from exhausted ones

2009-07-26 Thread Michal Kwiatkowski
On Jul 26, 1:10 am, Ben Finney ben+pyt...@benfinney.id.au wrote: Michal Kwiatkowski constant.b...@gmail.com 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:        

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

Re: strange error when trying to log something

2009-07-26 Thread Peter Otten
Aahz wrote: In article h49ah5$hv3$0...@news.t-online.com, 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

Re: code debugging

2009-07-26 Thread Gabriel Genellina
En Sun, 26 Jul 2009 03:33:27 -0300, golu bhardwajjaye...@gmail.com 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

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 behave

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: multiprocessing and __main__

2009-07-26 Thread iu2
On Jul 26, 8:52 am, is un israel.unter...@gmail.com 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    

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

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

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 see the future

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

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

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

2009-07-26 Thread Piet van Oostrum
MRAB pyt...@mrabarnett.plus.com (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

Re: PyQt GUI

2009-07-26 Thread Helvin
On Jul 24, 5:03 am, Robert Kern robert.k...@gmail.com 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

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

2009-07-26 Thread Aahz
In article h4gnmr$8c...@news.eternal-september.org, Raffael Cavallaro raffaelcavall...@pas.espam.s.il.vous.plait.mac.com wrote: On 2009-07-25 00:55:26 -0400, Carl Banks pavlovevide...@gmail.com said: But please don't put it on the same level as PHP. Their situations have almost nothing in

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 only

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

'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

Re: cgi.fieldstorage()

2009-07-26 Thread Diez B. Roggisch
gert schrieb: On Jul 25, 2:33 am, Diez B. Roggisch de...@nospam.web.de wrote: gert schrieb: On Jul 24, 7:32 pm, Diez B. Roggisch de...@nospam.web.de wrote: gert schrieb: this is a non standard way to store multi part post data on disk def application(environ, response): 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

Re: invoke method on many instances

2009-07-26 Thread Aahz
In article mailman.3648.1248429993.8015.python-l...@python.org, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Thu, 23 Jul 2009 21:27:35 -0300, Aahz a...@pythoncraft.com escribió: In article mailman.3561.1248307942.8015.python-l...@python.org, Gabriel Genellina gagsl-...@yahoo.com.ar wrote:

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

Re: python fast HTML data extraction library

2009-07-26 Thread John Machin
On Jul 23, 11:53 am, Paul McGuire pt...@austin.rr.com wrote: On Jul 22, 5:43 pm, Filip pink...@gmail.com wrote: # Needs re.IGNORECASE, and can have tag attributes, such as BR CLEAR=ALL line_break_re = re.compile('br\/?', re.UNICODE) Just in case somebody actually uses valid XHTML :-) it

Re: Override a method but inherit the docstring

2009-07-26 Thread Aahz
In article 056f629b-aa63-458a-ae16-ac40a759e...@h11g2000yqb.googlegroups.com, Shai s...@platonix.com 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

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

2009-07-26 Thread Piet van Oostrum
ryles ryle...@gmail.com (r) wrote: r On Jul 25, 8:57 am, Piet van Oostrum p...@cs.uu.nl wrote: ryles ryle...@gmail.com (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

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: pyc files not automatically compiled on import

2009-07-26 Thread Fuzzyman
On Jul 26, 5:22 pm, Baz Walter baz...@ftml.net 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,

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 pauljbar...@gmail.com 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

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

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: How do I generate dia diagrams from python source code?

2009-07-26 Thread Qauzzix
On Jul 25, 8:31 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Fri, 24 Jul 2009 17:52:47 -0300, Qauzzix qauz...@gmail.com 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

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

2009-07-26 Thread John Yeung
On Jul 26, 1:13 pm, Tom tom.su...@gmx.com 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: Removing newlines from string on windows (without replacing)

2009-07-26 Thread Aahz
In article mailman.3714.1248551656.8015.python-l...@python.org, Tom tom.su...@gmx.com 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

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 would

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

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 n...@craig-wood.com 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(work)  #

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 hend...@microcorp.co.za 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

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 na...@animats.com wrote: The idea: To run functions that execute a series of system commands without

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'm a

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

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 RD tool would be similar to Matlab or Mathematica but could be compiled to

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 any of the

Re: Can't get UDP example to work

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

Re: Can't get UDP example to work

2009-07-26 Thread Paul Barry
On Jul 26, 11:07 am, MRAB pyt...@mrabarnett.plus.com 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

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 Roy Smith
In article 2f578124-1ae3-45a5-a0c9-b8b05c0b5...@p23g2000vbl.googlegroups.com, Paul Barry pauljbar...@gmail.com 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

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

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 Roy Smith
In article h4gnmr$8c...@news.eternal-september.org, Raffael Cavallaro raffaelcavall...@pas.espam.s.il.vous.plait.mac.com 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

Re: invoke method on many instances

2009-07-26 Thread Gabriel Genellina
En Sun, 26 Jul 2009 12:44:02 -0300, Aahz a...@pythoncraft.com escribió: In article mailman.3648.1248429993.8015.python-l...@python.org, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Thu, 23 Jul 2009 21:27:35 -0300, Aahz a...@pythoncraft.com escribió: In article

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

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 r...@panix.com 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

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

Re: How to comment constant values?

2009-07-26 Thread Chris Rebert
On Sun, Jul 26, 2009 at 2:49 PM, Erwin Muellerdev...@deventm.org 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):

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

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

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 raffaelcavall...@pas.espam.s.il.vous.plait.mac.com 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

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: 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 Diez B. Roggisch
Chris Rebert schrieb: On Sun, Jul 26, 2009 at 2:49 PM, Erwin Muellerdev...@deventm.org 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

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

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 r...@panix.com wrote: In article 148abf0f-c9e4-4156-8f16-e4e5615d3...@s6g2000vbp.googlegroups.com,  Paul Barry pauljbar...@gmail.com wrote: host = '127.0.0.1'           # Bind to all interfaces This

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

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

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

Re: python fast HTML data extraction library

2009-07-26 Thread Filip
On Jul 23, 3:53 am, Paul McGuire pt...@austin.rr.com 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

Re: Distinguishing active generators from exhausted ones

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

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

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

Re: Mutable Strings - Any libraries that offer this?

2009-07-26 Thread Jack Diederich
On Mon, Jul 20, 2009 at 5:57 AM, casebashwalkr...@gmail.com 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

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 all()

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 late, I

Re: missing 'xor' Boolean operator

2009-07-26 Thread greg
Terry Reedy wrote: In Math and Python, abc means ab and bc, not (ab)c or a(bc). != is a comparison operator like , 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

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

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

Re: PyQt GUI

2009-07-26 Thread Robert Kern
On 2009-07-26 07:04, Helvin wrote: C:\Qt\VTKbin7\Wrapping\Pythonpython setup.py install Traceback (most recent call last): File setup.py, line 138, inmodule raise ERROR: Must specify BUILD_TYPE=config-name on command line. TypeError: exceptions must be classes or instances, not str Is

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

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

[issue481171] Hang using files named prn.txt, etc

2009-07-26 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue481171 ___ ___

[issue6574] List the __future__ features in a table

2009-07-26 Thread Ezio Melotti
New submission from Ezio Melotti ezio.melo...@gmail.com: The documentation about the __future__ features [1] only lists the features available for that particular version, without specifying when they were added and their effects. It would be nice to have a table with |feature|version

[issue6567] Make inf be almost equal to inf

2009-07-26 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: Sounds good to me. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6567 ___ ___

[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2009-07-26 Thread Ori Avtalion
Changes by Ori Avtalion o...@avtalion.name: -- nosy: +salty-horse ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1820 ___ ___ Python-bugs-list

  1   2   >