Re: C API String Parsing/Returning

2009-04-06 Thread k3xji
Whan I run the following function, I see a mem leak, a 20 mb of memory is allocated and is not freed. Here is the code I run: >>> import esauth >>> for i in range(100): ... ss = esauth.penc('sumer') ... >>> for i in range(100): ... ss = esauth.penc('sumer') ... And here is the pen

Anyone mannaged to access parallel port on windows xp?

2009-04-06 Thread alejandro
I have a switch that I should connect to the parallel port, but had no luck with it. Tha guy that made it for me told me that it would be easyer to connect via parallel instead the USB So did anyone have success? I only get suckess!! :-)) tryed giveio.sys but it doesn't wort (can't figure ou

Re: decorator module in stdlib?

2009-04-06 Thread Michele Simionato
On Apr 7, 7:57 am, Daniel Fetchinson wrote: > > have always seen the decorator module > > as a temporary hack waiting for a proper solution > > at the language level. I wanted the possibility to modify the > > signature of a function. Everybody more or less agreed > > that this was a good idea on

Re: decorator module in stdlib?

2009-04-06 Thread Daniel Fetchinson
>> Similar functionality is already provided by >> functools.update_wrapper() and functools.wraps(). >> Seehttp://docs.python.org/library/functools.html >> You might consider proposing the modification of these functions instead. > > Unfortunately functools.update_wrapper() and functools.wraps() >

Re: Returning different types based on input parameters

2009-04-06 Thread George Sakkis
On Apr 6, 7:57 pm, "andrew cooke" wrote: > andrew cooke wrote: > > George Sakkis wrote: > >> That's more of a general API design question but I'd like to get an > >> idea if and how things are different in Python context. AFAIK it's > >> generally considered bad form (or worse) for functions/metho

Re: in place list modification necessary? What's a better idiom?

2009-04-06 Thread Carl Banks
MooMaster wrote: > So I'm reading in values from a file, and for each column I need to > dynamically discover the range of possible values it can take and > quantize if necessary. This is the solution I've come up with: > > > def createInitialCluster(fileName): > #get the data from the file >

Re: decorators don't play nice with nose?

2009-04-06 Thread Michele Simionato
On Apr 6, 11:11 pm, "Diez B. Roggisch" wrote: > Nose works via the func_name parameter of a method/function. > > So when you decorate it, you need to make sure that is set properly. One > option is to do something like this: > > from functools import wraps > > def my_decorator(f): >     @wraps(f)

Re: decorator module in stdlib?

2009-04-06 Thread Michele Simionato
On Apr 7, 2:50 am, Chris Rebert wrote: > Similar functionality is already provided by > functools.update_wrapper() and functools.wraps(). > Seehttp://docs.python.org/library/functools.html > You might consider proposing the modification of these functions instead. Unfortunately functools.update_w

Re: more fun with iterators (mux, demux)

2009-04-06 Thread Miles
On Mon, Apr 6, 2009 at 10:05 PM, Steven D'Aprano wrote: > On Mon, 06 Apr 2009 20:05:51 -0400, Neal Becker wrote: > >> I'm trying to make a multiplexor and demultiplexor, using generators. >> The multiplexor will multiplex N sequences -> 1 sequence  (assume equal >> length). The demultiplexor will d

in place list modification necessary? What's a better idiom?

2009-04-06 Thread MooMaster
A similar discussion has already occurred, over 4 years ago: http://groups.google.com/group/comp.lang.python/browse_thread/thread/b806ada0732643d/5dff55826a199928?lnk=gst&q=list+in+place#5dff55826a199928 Nevertheless, I have a use-case where such a discussion comes up. For my data mining class I'm

Re: what does "execfile" mean within profiler output and why does it not have a attached line number

2009-04-06 Thread Robert Kern
On 2009-04-06 19:09, Rahul wrote: Robert Kern wrote in news:mailman.3316.1238893185.11746.python-l...@python.org: To quickly find your hotspots, start by sorting by 'time' (that would be displayed as the 'tottime' column in the human-readable output). That tells you how much time is spent in e

Re: more fun with iterators (mux, demux)

2009-04-06 Thread Miles
On Mon, Apr 6, 2009 at 8:05 PM, Neal Becker wrote: > I'm trying to make a multiplexor and demultiplexor, using generators.  The > multiplexor will multiplex N sequences -> 1 sequence  (assume equal length). > The demultiplexor will do the inverse. > > The demux has me stumped.  The demux should ret

RE: with open('com1', 'r') as f:

2009-04-06 Thread Lawrence D'Oliveiro
In message , Delaney, Timothy (Tim) wrote: > Lawrence D'Oliveiro wrote: > >> In message , >> Terry Reedy wrote: >> >>> Lawrence D'Oliveiro wrote: >>> All Python objects are reference-counted. >>> >>> Nope. Only in CPython, and even that could change. >> >> Why should it? > > Because G

Re: object knows which object called it?

2009-04-06 Thread Steven D'Aprano
On Mon, 06 Apr 2009 07:53:55 -0700, Reckoner wrote: > hi, > > I have the following problem: I have two objects, say, A and B, which > are both legitimate stand-alone objects with lives of their own. > > A contains B as a property, so I often do > > A.B.foo() > > the problem is that some functi

Re: How to go about. On read/write locks

2009-04-06 Thread Carl Banks
On Apr 6, 2:23 pm, "Diez B. Roggisch" wrote: > > This is a classical synchronization problem with a classical solution: > > You treat the readers as a group, and the writers individually. So you > > have a write lock that each writer has to acquire and release, but it is > > acquired only by the f

Re: more fun with iterators (mux, demux)

2009-04-06 Thread Steven D'Aprano
On Mon, 06 Apr 2009 20:05:51 -0400, Neal Becker wrote: > I'm trying to make a multiplexor and demultiplexor, using generators. > The multiplexor will multiplex N sequences -> 1 sequence (assume equal > length). The demultiplexor will do the inverse. > > The mux seems easy enough: > > -

Re: How to go about. On read/write locks

2009-04-06 Thread Carl Banks
On Apr 6, 3:30 am, "Emanuele D'Arrigo" wrote: > Python's approach with the GIL is both reasonable and disappointing. > Reasonable because I understand how it can make things easier for its > internals. Disappointing because it means that standard python cannot > take advantage of the parallelism t

Re: decorator module in stdlib?

2009-04-06 Thread Chris Rebert
On Mon, Apr 6, 2009 at 5:41 PM, Daniel Fetchinson wrote: > The decorator module [1] written by Michele Simionato is a very useful > tool for maintaining function signatures while applying a decorator. > Many different projects implement their own versions of the same > functionality, for example t

decorator module in stdlib?

2009-04-06 Thread Daniel Fetchinson
The decorator module [1] written by Michele Simionato is a very useful tool for maintaining function signatures while applying a decorator. Many different projects implement their own versions of the same functionality, for example turbogears has its own utility for this, I guess others do somethin

Re: what does "execfile" mean within profiler output and why does it not have a attached line number

2009-04-06 Thread Rahul
Robert Kern wrote in news:mailman.3316.1238893185.11746.python-l...@python.org: > To quickly find your hotspots, start by sorting by 'time' (that would > be displayed as the 'tottime' column in the human-readable output). > That tells you how much time is spent in each function itself, > excludi

Re: Web validation

2009-04-06 Thread Chris Rebert
On Mon, Apr 6, 2009 at 3:44 PM, r-w wrote: > If no internet connection: Try loading http://example.com using urllib (http://docs.python.org/library/urllib.html). If an exception gets raised, you're not connected (properly). Cheers, Chris -- I have a blog: http://blog.rebertia.com -- http://mai

more fun with iterators (mux, demux)

2009-04-06 Thread Neal Becker
I'm trying to make a multiplexor and demultiplexor, using generators. The multiplexor will multiplex N sequences -> 1 sequence (assume equal length). The demultiplexor will do the inverse. The mux seems easy enough: --- def mux (*ranges): iterables = [iter (r) for r i

RE: with open('com1', 'r') as f:

2009-04-06 Thread Delaney, Timothy (Tim)
Lawrence D'Oliveiro wrote: > In message , > Terry Reedy wrote: > >> Lawrence D'Oliveiro wrote: >> >>> All Python objects are reference-counted. >> >> Nope. Only in CPython, and even that could change. > > Why should it? Because Guido has said it might some time in the future. >>> Once the f

Re: Returning different types based on input parameters

2009-04-06 Thread andrew cooke
andrew cooke wrote: > George Sakkis wrote: >> That's more of a general API design question but I'd like to get an >> idea if and how things are different in Python context. AFAIK it's >> generally considered bad form (or worse) for functions/methods to >> return values of different "type" depending

Re: Returning different types based on input parameters

2009-04-06 Thread andrew cooke
George Sakkis wrote: > That's more of a general API design question but I'd like to get an > idea if and how things are different in Python context. AFAIK it's > generally considered bad form (or worse) for functions/methods to > return values of different "type" depending on the number, type and/o

Re: New online docs broken?

2009-04-06 Thread Ye Liu
On Apr 6, 6:33 pm, Jim Garrison wrote: > I notice the online docs (at docs.python.org/3.0/index.html) were > updated today.  It seems some of the top-level pages, like > Tutorial, "Using Python", "Language Reference" are truncated > after the first few paragraphs. Yea, same here. Hope it's going

Re: speed of string chunks file parsing

2009-04-06 Thread John Machin
On Apr 6, 11:48 pm, Hyunchul Kim wrote: > Hi, all > > I have a simple script. > Can you improve algorithm of following 10 line script, with a view point > of speed ? > Following script do exactly what I want but I want to improve the speed. So the first thing to do is to try to work out where it

Re: Returning different types based on input parameters

2009-04-06 Thread George Sakkis
On Apr 6, 5:56 pm, MRAB wrote: > In your example I would possibly suggest returning a 'Result' object and > then later subclassing to give 'ConfidenceResult' which has the > additional 'confidence' attribute. That's indeed one option, but not very appealing if `Result` happens to be a builtin (e

Re: group several methods under a attribute

2009-04-06 Thread Rhodri James
On Mon, 06 Apr 2009 20:52:50 +0100, jelle wrote: Hi Aaron, Thanks a lot for your suggestions. I wasnt familiar with the __get__ magic, which seems interesting. So, finally it seems that the cleanest pattern is: class ClsA( object ): def __init__( self, other ): self.inst= other

Re: Returning different types based on input parameters

2009-04-06 Thread Steven D'Aprano
On Mon, 06 Apr 2009 14:02:26 -0700, George Sakkis wrote: > That's more of a general API design question but I'd like to get an idea > if and how things are different in Python context. AFAIK it's generally > considered bad form (or worse) for functions/methods to return values of > different "type

Web validation

2009-04-06 Thread r-w
If no internet connection: if have files: run anyway, with warning else: ERROR else: if error getting hash/files: if have files: run anyway, with warning else: ERROR else: run -- http://mail.python.org/mailman/listinfo

Re: extract Infobox contents

2009-04-06 Thread Rhodri James
On Mon, 06 Apr 2009 23:12:14 +0100, Anish Chapagain wrote: Hi, I was trying to extract wikipedia Infobox contents which is in format like given below, from the opened URL page in Python. {{ Infobox Software | name = Bash | logo = [[Image:bash-org.png|165px

Re: Eval Problem

2009-04-06 Thread J. Clifford Dyer
On Mon, 2009-04-06 at 15:11 -0400, Victor Subervi wrote: > Hi: > I have this code: > > x = 1 > while x <= bitties: > file = open(p + str(x) + ".txt") > for line in file: > print line > print eval(bits[x - 1]) > x += 1 > > which throws this error: > > [Mon Apr 06 12:07:29 2009] [error

New online docs broken?

2009-04-06 Thread Jim Garrison
I notice the online docs (at docs.python.org/3.0/index.html) were updated today. It seems some of the top-level pages, like Tutorial, "Using Python", "Language Reference" are truncated after the first few paragraphs. -- http://mail.python.org/mailman/listinfo/python-list

How can I change size of GUI?

2009-04-06 Thread Muddy Coder
Hi Folks, I copied code from book: class ScrolledText(Frame): def __init__(self, parent=None, text='', file=None): Frame.__init__(self, parent) self.pack(expand=YES, fill=BOTH) self.makeWidgets() self.settext(text, file)

Some test fail on my new Python 2.6

2009-04-06 Thread R. David Murray
Sorin Schwimmer wrote: > I just downloaded and compiled Python 2.6 on a Gentoo Linux, IBM NetVista. > > After going through the usual steps (./configure, make), I ran a test (make > test), and got some unexpected issues, which are detailed here: > > # ./python Lib/test/test_tcl.py > Traceback (

Re: Best way to start

2009-04-06 Thread namekuseijin
Google's automatic chat logging is nice too. My first online python tutorial for someone who never saw it before (sorry for not being in english): 14/09/08 00:50 KALEL: I'm on Phyton Shell 00:52 me: cool let's go type it: 2 just to get rid of your fears... :) KALEL: Hah hah hah hah me:

extract Infobox contents

2009-04-06 Thread Anish Chapagain
Hi, I was trying to extract wikipedia Infobox contents which is in format like given below, from the opened URL page in Python. {{ Infobox Software | name = Bash | logo = [[Image:bash-org.png|165px]] | screenshot = [[Image:Bash demo.png|250px]] | cap

Re: Weird Tk Canvas coordinate issue

2009-04-06 Thread John Posner
Tim Shannon wrote: I'm new to python, so keep that in mind. I have a tk Canvas that I'm trying to draw on, and I want to start my drawing at an offset (from 0) location. So I can tweak this as I code, I set this offset as a class level variable: def ClassName: OFFSET = 20 def __i

Re: print from a python script.

2009-04-06 Thread R. David Murray
Chris Rebert wrote: > On Mon, Apr 6, 2009 at 2:24 PM, Ronn Ross wrote: > > I'm trying to print a simple string to a network printer. This is what I > > have so far: > > > > import os > > > > printer_path = "192.168.200.139" > > p = os.popen(printer_path, 'w') > > p.write("this is a printer test")

Re: Returning different types based on input parameters

2009-04-06 Thread MRAB
George Sakkis wrote: That's more of a general API design question but I'd like to get an idea if and how things are different in Python context. AFAIK it's generally considered bad form (or worse) for functions/methods to return values of different "type" depending on the number, type and/or valu

Re: Best way to start

2009-04-06 Thread namekuseijin
Avi escreveu: A BIG Thanks to Chris and Andrew for suggestions. This is an awesome place. namekuseijin: haha...got a friend hooked to Python on chat? hilarious! True story. But he was already a programmer. Only Pascal Delphi though. -- a game sig: http://tinyurl.com/d3rxz9 -- http://mail.p

Re: How to go about. On read/write locks

2009-04-06 Thread Diez B. Roggisch
Python's approach with the GIL is both reasonable and disappointing. Reasonable because I understand how it can make things easier for its internals. Disappointing because it means that standard python cannot take advantage of the parallelism that can more and more often be afforded by today's com

Re: print from a python script.

2009-04-06 Thread Chris Rebert
On Mon, Apr 6, 2009 at 2:24 PM, Ronn Ross wrote: > I'm trying to print a simple string to a network printer. This is what I > have so far: > > import os > > printer_path = "192.168.200.139" > p = os.popen(printer_path, 'w') > p.write("this is a printer test") > p.close() > > I'm trying to call the

Re: How to go about. On read/write locks

2009-04-06 Thread Diez B. Roggisch
This is a classical synchronization problem with a classical solution: You treat the readers as a group, and the writers individually. So you have a write lock that each writer has to acquire and release, but it is acquired only by the first reader and released by the last one. Therefore you need

print from a python script.

2009-04-06 Thread Ronn Ross
I'm trying to print a simple string to a network printer. This is what I have so far: import os printer_path = "192.168.200.139" p = os.popen(printer_path, 'w') p.write("this is a printer test") p.close() I'm trying to call the printer from its IP address. When I run the script I get: sh: 192.16

Re: decorators don't play nice with nose?

2009-04-06 Thread Diez B. Roggisch
hyperboreean schrieb: Hi, I am trying to test the business part of a web service. For this I am using unittest & nose. I wrote a decorator that should handle the xml test file retrieval, but it seems I can't get it working with nose. Here's the code: * MyApp.py -- base test class * import os

Re: Best way to start

2009-04-06 Thread Avi
A BIG Thanks to Chris and Andrew for suggestions. This is an awesome place. namekuseijin: haha...got a friend hooked to Python on chat? hilarious! -- http://mail.python.org/mailman/listinfo/python-list

Some test fail on my new Python 2.6

2009-04-06 Thread Sorin Schwimmer
Hi All, I just downloaded and compiled Python 2.6 on a Gentoo Linux, IBM NetVista. After going through the usual steps (./configure, make), I ran a test (make test), and got some unexpected issues, which are detailed here: # ./python Lib/test/test_tcl.py Traceback (most recent call last): Fi

Returning different types based on input parameters

2009-04-06 Thread George Sakkis
That's more of a general API design question but I'd like to get an idea if and how things are different in Python context. AFAIK it's generally considered bad form (or worse) for functions/methods to return values of different "type" depending on the number, type and/or values of the passed parame

Re: Best way to start

2009-04-06 Thread namekuseijin
I was able to get a friend into Python over a Google Chat. I pointed him to the downloads page, waited for him to install, then covered the basics in quite a few steps (syntax, conditionals, loops, function definition and application, classes and methods, lists, dicts and comprehensions). He

Re: Best way to start

2009-04-06 Thread Tim Shannon
I personally learned a lot from www.diveintopython.org On Mon, Apr 6, 2009 at 2:08 PM, Avi wrote: > Hi, > > What is a good way to learn Python? > > Do you recommend going by a book (suggestions welcome) or learning > with tutorials? Both? > > Thanks in advance, > Avi > -- > http://mail.python.or

Re: Best way to start

2009-04-06 Thread andrew cooke
Avi wrote: > What is a good way to learn Python? > > Do you recommend going by a book (suggestions welcome) or learning > with tutorials? Both? how do you like to learn and how much experience do you have programming in other languages? andrew -- http://mail.python.org/mailman/listinfo/python-l

Re: object knows which object called it?

2009-04-06 Thread George Sakkis
On Apr 6, 10:53 am, Reckoner wrote: > hi, > > I have the following problem: I have two objects, say, A and B, which > are both legitimate stand-alone objects with lives of their own. > > A contains B as a property, so I often do > > A.B.foo() > > the problem is that some functions inside of B actu

Re: group several methods under a attribute

2009-04-06 Thread jelle
Hi Aaron, Thanks a lot for your suggestions. I wasnt familiar with the __get__ magic, which seems interesting. So, finally it seems that the cleanest pattern is: class ClsA( object ): def __init__( self, other ): self.inst= other def submethA( self, arg ): print( 'submet

cgi file limit size?

2009-04-06 Thread davidj411
I am wondering where the limitation of filesize comes from when i upload a large file. it uploads when the filesize is less than 20 MB (but not if larger). the script does not limit the filesize so it is either an HTTP specification or a webserver limit, right? maybe my connection to the server is

Weird Tk Canvas coordinate issue

2009-04-06 Thread Tim Shannon
I'm new to python, so keep that in mind. I have a tk Canvas that I'm trying to draw on, and I want to start my drawing at an offset (from 0) location. So I can tweak this as I code, I set this offset as a class level variable: def ClassName: OFFSET = 20 def __init__(self, master)):

Re: Best way to start

2009-04-06 Thread Chris Rebert
On Mon, Apr 6, 2009 at 12:08 PM, Avi wrote: > Hi, > > What is a good way to learn Python? > > Do you recommend going by a book (suggestions welcome) or learning > with tutorials? Both? The official Python tutorial is pretty darn good: http://docs.python.org/tutorial/ If you want a book as well, I

Eval Problem

2009-04-06 Thread Victor Subervi
Hi: I have this code: x = 1 while x <= bitties: file = open(p + str(x) + ".txt") for line in file: print line print eval(bits[x - 1]) x += 1 which throws this error: [Mon Apr 06 12:07:29 2009] [error] [client 190.166.0.221] PythonHandler mod_python.cgihandler: Traceback (most recent

Best way to start

2009-04-06 Thread Avi
Hi, What is a good way to learn Python? Do you recommend going by a book (suggestions welcome) or learning with tutorials? Both? Thanks in advance, Avi -- http://mail.python.org/mailman/listinfo/python-list

Re: Executing a C program from Python

2009-04-06 Thread Brent Bloxam
vishakha vaibhav wrote: Hi, I am very new to python. I have my cgi script written in Python. My CGI script should call a C program and collect the value returned by this program and pass it to the browser. Can anyone help me out in this. How can I execute the c program and collect the return

Re: Delicious API and urllib2

2009-04-06 Thread Brent Bloxam
Bill wrote: The delicious api requires http authorization (actually https). A generic delicious api post url is "https:// username:passw...@api.api.del.icio.us/v1/posts/add?url=http:// example.com/&description=interesting&tags=whatever". This works fine when entered in the Firefox address bar. H

Re: Accessing mail box tree of Thunderbird/Seamonkey?

2009-04-06 Thread robert
Chris Rebert wrote: On Sun, Apr 5, 2009 at 1:04 AM, robert wrote: Is there a API/possibilty for reading&writing (live) in the mail box tree of Thunderbird/Seamonkey with Python? From what I can google, they're already in mbox format, so you can use mailbox.mbox to read/write to them. See ht

Re: logging - string formating problems

2009-04-06 Thread Vinay Sajip
On Apr 6, 1:58 pm, "Werner F. Bruhin" wrote: > I am fully aware that the problem is in my code, however as getMessage > inlogging.__init__.py does not catch the exception it is pretty > difficult to find the problem without manually inspecting > anylogging.something statements. > > My hack oflogg

pycap (popcap gaming lib w python 2.5) mouse question

2009-04-06 Thread eric_dex...@msn.com
anyone use pycap based on popcap gaming lib.. http://www.farbs.org/pycap.html?? (not to be confused with the other pycap) I was trying to figure out why the mouse works in the example I didn't see any python code for it but It seem to have an effect in the example.. -- http://mail.python.org/mail

Delicious API and urllib2

2009-04-06 Thread Bill
The delicious api requires http authorization (actually https). A generic delicious api post url is "https:// username:passw...@api.api.del.icio.us/v1/posts/add?url=http:// example.com/&description=interesting&tags=whatever". This works fine when entered in the Firefox address bar. However urllib2

Re: Help with wxPython program :.: return 1?

2009-04-06 Thread Trent Mick
Dennis Lee Bieber wrote: I don't know what Komodo is coded in, but if it is using wx, you may be failing from having two "mainloop" processes... (same problem as trying to run a Tkinter application from inside IDLE, and probably trying to run a win32gui application from PythonWin) No, K

Re: Cannot find text in *.py files with Windows Explorer?

2009-04-06 Thread Ant
On Apr 4, 7:09 am, Tim Golden wrote: > ... Now I think about it, try searching > for "xplorer2" ... I'll second that. It's one of the few non-open source bits of software that I'll willingly pay a license for. Have used it for around 5 or 6 years now. It's by a little 1 man company called Zabkat.

Re: An executable operational semantics for Python

2009-04-06 Thread Piet van Oostrum
> bearophileh...@lycos.com (b) wrote: >b> gideon: >>> I've recently finished my Master's thesis on the semantics of Python. >>> In my thesis I define the semantics of Python by rewriting an abstract >>> machine. The sources that are used to produce my thesis can also be >>> compiled into a wor

Re: group several methods under a attribute

2009-04-06 Thread Aaron Brady
On Apr 6, 12:02 pm, Aaron Brady wrote: > On Apr 6, 5:40 am, jelle wrote: > > > Hi, > > > I'm working on a pretty large class and I'd like to group several > > methods under a attribute. > > Its not convenient to chop up the class in several smaller classes, > > nor would mixins really solve the i

Executing a C program from Python

2009-04-06 Thread vishakha vaibhav
Hi, I am very new to python. I have my cgi script written in Python. My CGI script should call a C program and collect the value returned by this program and pass it to the browser.   Can anyone help me out in this. How can I execute the c program and collect the return value.   I tried, import

Randomized Incremental Decision Tree

2009-04-06 Thread razafindrazaka faniry harijaona
Hello, How to model this problem as a python code: Starting with a general condition A, we enter a statement 'p' , if p satisfy A which is always the case, then split A to three sub-conditions A1,A2,A3. And we enter again a statement p1: if p1 satisfy A: if p1 satis

Re: object knows which object called it?

2009-04-06 Thread Anthra Norell
Reckoner wrote: hi, I have the following problem: I have two objects, say, A and B, which are both legitimate stand-alone objects with lives of their own. A contains B as a property, so I often do A.B.foo() the problem is that some functions inside of B actually need A (remember I said they w

Injecting python function in an embedded python engine

2009-04-06 Thread Roberto Fichera
Hi All in the list, I've embedded python v2.6.x engine into my application without any problem. Now I would like to inject some additional functions after importing a python module. So, basically I'm importing a python module via PyImport_ImportModule() function. The python module is a simple set

set python default encoding

2009-04-06 Thread R. David Murray
reetesh nigam wrote: > Hi All, > I am unable to set the python default encoding. > i used the following proccess to set the python encoding > > import sys > reload(sys) > sys.setdefaultencoding('latin-1') > > but it is giving me the same error : > > args = ('utf8', "MEDICINE '\xc4 ", 10,

Re: object knows which object called it?

2009-04-06 Thread Duncan Booth
Reckoner wrote: > hi, > > I have the following problem: I have two objects, say, A and B, which > are both legitimate stand-alone objects with lives of their own. > > A contains B as a property, so I often do > > A.B.foo() > > the problem is that some functions inside of B actually need A > (

Re: object knows which object called it?

2009-04-06 Thread Aaron Brady
On Apr 6, 9:53 am, Reckoner wrote: > hi, > > I have the following problem: I have two objects, say, A and B, which > are both legitimate stand-alone objects with lives of their own. > > A contains B as a property, so I often do > > A.B.foo() > > the problem is that some functions inside of B actua

Re: group several methods under a attribute

2009-04-06 Thread Aaron Brady
On Apr 6, 5:40 am, jelle wrote: > Hi, > > I'm working on a pretty large class and I'd like to group several > methods under a attribute. > Its not convenient to chop up the class in several smaller classes, > nor would mixins really solve the issue. > So, what is a pythonic way of grouping several

object knows which object called it?

2009-04-06 Thread R. David Murray
Reckoner wrote: > hi, > > I have the following problem: I have two objects, say, A and B, which > are both legitimate stand-alone objects with lives of their own. > > A contains B as a property, so I often do > > A.B.foo() > > the problem is that some functions inside of B actually need A > (r

Re: Example for readline module usage?

2009-04-06 Thread Peter Otten
Grant Edwards wrote: > On 2009-04-06, Peter Otten <__pete...@web.de> wrote: >> Grant Edwards wrote: >> >>> [I swear I've asked this question before, but Google can't find >>> it.] >> >> My Google is better than yours then: >> >> http://mail.python.org/pipermail/python-list/2008-July/669582.html >

Re: speed of string chunks file parsing

2009-04-06 Thread andrew cooke
[disclaimer - this is just guessing from general knowledge of regular expressions; i don't know any details of python's regexp engine] if your regular expression is the bottleneck rewrite it to avoid lazy matching, references, groups, lookbacks, and perhaps even counted repeats. with a little th

Re: [Python-Dev] PEP 382: Namespace Packages

2009-04-06 Thread Jesse Noller
On Mon, Apr 6, 2009 at 9:26 AM, Barry Warsaw wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On Apr 6, 2009, at 9:21 AM, Jesse Noller wrote: > >> On Thu, Apr 2, 2009 at 4:33 PM, M.-A. Lemburg wrote: >>> >>> On 2009-04-02 17:32, Martin v. Löwis wrote: I propose the following

Re: [Python-Dev] PEP 382: Namespace Packages

2009-04-06 Thread Chris Withers
P.J. Eby wrote: See the third paragraph of http://www.python.org/dev/peps/pep-0382/#discussion Indeed, I guess the PEP could be made more explanatory then 'cos, as a packager, I don't see what I'd put in the various setup.py and __init__.py to make this work... That said, I'm delighted to

Re: speed of string chunks file parsing

2009-04-06 Thread bearophileHUGS
bearophile: >     cp_regular_expression = re.compile("^a complex regular expression > here$") >     for line in file(inputfile): >         if cp_regular_expression.match(line) and result_seq: Sorry, you can replace that with: cp_regular_expression = re.compile("^a complex regular expression h

Re: speed of string chunks file parsing

2009-04-06 Thread bearophileHUGS
Hyunchul Kim: > Following script do exactly what I want but I want to improve the speed. This may be a bit faster, especially if sequences are long (code untested): import re from collections import deque def scanner1(deque=deque): result_seq = deque() cp_regular_expression = re.compile

Re: [Python-Dev] PEP 382: Namespace Packages

2009-04-06 Thread P.J. Eby
At 02:00 PM 4/6/2009 +0100, Chris Withers wrote: Martin v. Löwis wrote: Chris Withers wrote: Would this support the following case: I have a package called mortar, which defines useful stuff: from mortar import content, ... I now want to distribute large optional chunks separately, but ideal

Re: group several methods under a attribute

2009-04-06 Thread jelle
> Whatever it is, you should find a better way instead of cramming > everything into a single class. That smells of the God Object > antipattern (http://en.wikipedia.org/wiki/God_object). Thanks Gerard, I'll take your advice. -jelle -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] PEP 382: Namespace Packages

2009-04-06 Thread Eric Smith
> -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On Apr 6, 2009, at 9:21 AM, Jesse Noller wrote: > >> On Thu, Apr 2, 2009 at 4:33 PM, M.-A. Lemburg wrote: >>> On 2009-04-02 17:32, Martin v. Löwis wrote: I propose the following PEP for inclusion to Python 3.1. >>> >>> Thanks for picking t

object knows which object called it?

2009-04-06 Thread Reckoner
hi, I have the following problem: I have two objects, say, A and B, which are both legitimate stand-alone objects with lives of their own. A contains B as a property, so I often do A.B.foo() the problem is that some functions inside of B actually need A (remember I said they were both standalon

Re: Q: "Best" book for teaching

2009-04-06 Thread Reckoner
On Apr 6, 7:37 am, grkunt...@gmail.com wrote: > I am considering teaching an "introduction to programming" course for > continuing education adults at a local community college. These would > people with no programming experience, but I will require a reasonable > facility with computers. > > What

Re: Example for readline module usage?

2009-04-06 Thread Grant Edwards
On 2009-04-06, Peter Otten <__pete...@web.de> wrote: > Grant Edwards wrote: > >> [I swear I've asked this question before, but Google can't find >> it.] > > My Google is better than yours then: > > http://mail.python.org/pipermail/python-list/2008-July/669582.html It certainly is. All I could com

Q: "Best" book for teaching

2009-04-06 Thread grkuntzmd
I am considering teaching an "introduction to programming" course for continuing education adults at a local community college. These would people with no programming experience, but I will require a reasonable facility with computers. What would be a good book to use as the text for the course?

Re: Killing threads

2009-04-06 Thread Aahz
In article <685a59cd-9f02-483f-bc59-b55091a18...@u9g2000pre.googlegroups.com>, imageguy wrote: >Aahz: >> >>For more info, see the slides from my thread tutorial: >>http://pythoncraft.com/OSCON2001/ > >Aahz, thanks for this reference and link to your presentation. At the >risk of highjacking the

Re: Killing threads

2009-04-06 Thread Aahz
In article , wrote: > >I know that killing threads is hard in any language (I'm facing now >the issue in a C++ program I'm writing at work), expecially doing in a >platform-independent way, but Java managed to do it. That's not my understanding: http://www.roseindia.net/javatutorials/shutting_d

Re: decorators don't play nice with nose?

2009-04-06 Thread J Kenneth King
hyperboreean writes: > From: hyperboreean > Subject: decorators don't play nice with nose? > Newsgroups: comp.lang.python > To: python-list@python.org > Date: Mon, 06 Apr 2009 11:01:04 +0300 > > Hi, I am trying to test the business part of a web service. For this I > am using unittest & nose. >

Re: speed of string chunks file parsing

2009-04-06 Thread MRAB
Hyunchul Kim wrote: Hi, all I have a simple script. Can you improve algorithm of following 10 line script, with a view point of speed ? Following script do exactly what I want but I want to improve the speed. This parse a file and accumulate lines till a line match a given regular expression

speed of string chunks file parsing

2009-04-06 Thread Hyunchul Kim
Hi, all I have a simple script. Can you improve algorithm of following 10 line script, with a view point of speed ? Following script do exactly what I want but I want to improve the speed. This parse a file and accumulate lines till a line match a given regular expression. Then, when a line m

Re: C API String Parsing/Returning

2009-04-06 Thread Christian Heimes
Gerhard Häring wrote: > char* buf = strdup(s); > if (!buf) { > PyErr_SetString(PyExc_MemoryError, "Out of memory: strdup failed"); > return NULL; > } > > /* TODO: your string manipulation */ Don't forget to free(buf). ;) Christian -- http://mail.python.org/mailman/listinfo/python-list

Newbie: Development plaform

2009-04-06 Thread Hermann Wehrmeyer
Hi, I am looking for an old school friend of mine, Demos Economacos. Are you perhaps the Demos who completed schooling 1979 at Kroonstad SA. Groete/Greetings Hermann Wehrmeyer Tel: 012 342 3710 Fax: 012 342 3775 -- http://mail.python.org/mailman/listinfo/python-list

Re: logging - string formating problems

2009-04-06 Thread MRAB
Werner F. Bruhin wrote: I am fully aware that the problem is in my code, however as getMessage in logging.__init__.py does not catch the exception it is pretty difficult to find the problem without manually inspecting any logging.something statements. My hack of logging.py is really a hack an

  1   2   >