Re: the C header file when extending CPython

2011-01-11 Thread Ulrich Eckhardt
Yingjie Lan wrote: > I am wondering when extending Python (CPython), what should be put into > the C header file? Any guidelines? You don't even need to write a header file at all. There are no Python- specific requirements to put anything into a header file, though you might want to do so for re

Re: Ideas for a module to process command line arguments

2011-01-11 Thread Michele Simionato
On Jan 11, 6:57 pm, Mike wrote: > On Jan 11, 11:26 am, Michele Simionato > wrote: > > In that case easy_install/pip/whatever will install the dependency > > automatically (who is installing > > dependencies by hand nowadays?). > > I do. Is this bad? :} You are simply spending more time than need

Re: Ideas for a module to process command line arguments

2011-01-11 Thread Michele Simionato
On Jan 11, 4:06 pm, Alice Bevan–McGregor wrote: > After looking into it, Plac's default help display isn't very helpful; > you need to massage your application a fair amount before generating > nice, complete-looking argument lists and such.  For example: > >         def main(verbose: ('prints mor

Re: Syntactic structure for 'until :' loop

2011-01-11 Thread eblume
On Jan 11, 6:53 pm, Ian Kelly wrote: > On 1/11/2011 7:22 PM, eblume wrote: > > > > > reader_iter = iter(self.reader) > headers = reader_iter.next() > # intermediate code > for line in reader_iter: >      data.append(line) > return data > > Also note that recommended best practice is to wrap the "

the C header file when extending CPython

2011-01-11 Thread Yingjie Lan
Hi, I am wondering when extending Python (CPython), what should be put into the C header file? Any guidelines? Thanks, Yingjie -- http://mail.python.org/mailman/listinfo/python-list

Re: Python use growing fast

2011-01-11 Thread Josh Benner
On Tue, Jan 11, 2011 at 6:38 PM, Sachin Kumar Sharma wrote: > Since this discussion is going on about the popularity of a programming > language. > > I would like to know views regarding the best language for scientific > programming especially in terms of user friendliness, resources available, >

Re: os.path.realpath() and os.path.abspath()

2011-01-11 Thread Adam Skutt
On Jan 11, 6:35 am, Jurko Gospodnetić wrote: >    Hi all. > >    os.path.realpath() documentation states that it returns a 'canonical' > path. Does that infer that it returns an absolute path? > A canonical path is supposed to be absolute and at least Python 2.7.1 ensures that is the case. Histo

Re: Parsing string for " "

2011-01-11 Thread MRAB
On 12/01/2011 01:50, Daniel da Silva wrote: Hi, I have come across a task where I would like to scan a short 20-80 character line of text for instances of " ". Ideally could be of any tense. I know quite a bit of programming and computer science, but computational linguistics is relatively n

Re: Syntactic structure for 'until :' loop

2011-01-11 Thread Ian Kelly
On 1/11/2011 7:22 PM, eblume wrote: This would be exactly equivalent to (but much more compact than): while True: try: do_something() except Exception: break Or perhaps: try: while True: do_something() except Exception: pass Now, why would anyone

RE: Python use growing fast

2011-01-11 Thread Sachin Kumar Sharma
Since this discussion is going on about the popularity of a programming language. I would like to know views regarding the best language for scientific programming especially in terms of user friendliness, resources available, graphics and robustness to handle large numerical and simulation pro

Syntactic structure for 'until :' loop

2011-01-11 Thread eblume
I'm still quite new to Python and I'm probably going about this entirely the wrong way, but it recently struck me that there might be the need for a control flow loop based on exception handling. First let me give the proposed syntax: until : do_something() This would be exactly equivalent to

Parsing string for " "

2011-01-11 Thread Daniel da Silva
Hi, I have come across a task where I would like to scan a short 20-80 character line of text for instances of " ". Ideally could be of any tense. I know quite a bit of programming and computer science, but computational linguistics is relatively new to me. If anyone can point me in the right di

Re: order of importing modules

2011-01-11 Thread Ben Finney
Catherine Moroney writes: > In what order does python import modules on a Linux system? An import caused by a statement is done when that statement is executed. So the answer to that question is: in the order the statements occur in the execution flow. > I have a package that is both installed

Re: order of importing modules

2011-01-11 Thread Dan Stromberg
On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney wrote: > In what order does python import modules on a Linux system?  I have a > package that is both installed in /usr/lib64/python2.5/site-packages, > and a newer version of the same module in a working directory. > > I want to import the versio

Re: How to dump a Python 2.6 dictionary with UTF-8 strings?

2011-01-11 Thread W. Martin Borgert
On 2011-01-12 00:27, Martin v. Loewis wrote: > This will work. I doubt you can get it much simpler > in 2.x; in 3.x, your code will work out of the box > (with proper syntactical adjustments). Thanks, this works like a charm. I tried pprint before for this task and failed. Now I know why :~) -- h

order of importing modules

2011-01-11 Thread Catherine Moroney
In what order does python import modules on a Linux system? I have a package that is both installed in /usr/lib64/python2.5/site-packages, and a newer version of the same module in a working directory. I want to import the version from the working directory, but when I print module.__file__ in

Re: Convert unicode escape sequences to unicode in a file

2011-01-11 Thread Jeremy
On Tuesday, January 11, 2011 3:36:26 PM UTC-7, Alex wrote: > > Are you _sure_ that your file contains the characters '\', 'u', '0', > '0', 'e' and '9'? I expect that actually your file contains a byte > with value 0xe9 and you have inspected the file using Python, which > has printed the byte usi

Re: How to dump a Python 2.6 dictionary with UTF-8 strings?

2011-01-11 Thread Alex Willmer
On Jan 11, 10:40 pm, "W. Martin Borgert" wrote: > Hi, > > naively, I thought the following code: > > #!/usr/bin/env python2.6 > # -*- coding: utf-8 -*- > import codecs > d = { u'key': u'我爱中国人' } > if __name__ == "__main__": >     with codecs.open("ilike.txt", "w", "utf-8") as f: >         print >>

Please use the Python Job Board for recruitment (was: Req: Python Developer : Direct CLient)

2011-01-11 Thread Ben Finney
nitin writes: > Please send me your resume if you are interested in it. Please don't use this forum for recruitment purposes. Instead, please use the Python Job Board http://www.python.org/community/jobs/>. -- \ “For every complex problem, there is a solution that is simple, | `\

Re: How to dump a Python 2.6 dictionary with UTF-8 strings?

2011-01-11 Thread Martin v. Loewis
> What's the right way to get the strings in UTF-8? This will work. I doubt you can get it much simpler in 2.x; in 3.x, your code will work out of the box (with proper syntactical adjustments). import pprint, cStringIO class UniPrinter(pprint.PrettyPrinter): def format(self, obj, context, ma

How to dump a Python 2.6 dictionary with UTF-8 strings?

2011-01-11 Thread W. Martin Borgert
Hi, naively, I thought the following code: #!/usr/bin/env python2.6 # -*- coding: utf-8 -*- import codecs d = { u'key': u'我爱中国人' } if __name__ == "__main__": with codecs.open("ilike.txt", "w", "utf-8") as f: print >>f, d would produce a file ilike.txt like this: {u'key': u'我爱中国人'}

Req: Python Developer : Direct CLient

2011-01-11 Thread nitin
Hi, Please send me your resume if you are interested in it. Python Developer Location: Sebastapol, CA Duration: 3 Months Python web application development. Systems integration. RESTful architectures and Web standards. Familiar with the following: JVM and java tools. Creating document

Re: Convert unicode escape sequences to unicode in a file

2011-01-11 Thread Alex Willmer
On Jan 11, 8:53 pm, Jeremy wrote: > I have a file that has unicode escape sequences, i.e., > > J\u00e9r\u00f4me > > and I want to replace all of them in a file and write the results to a new > file.  The simple script I've created is copied below.  However, I am getting > the following error: >

Re: Integrating doctest with unittest

2011-01-11 Thread SegundoBob
On Jan 9, 6:14 pm, Steven D'Aprano wrote: > >>Is there a way to have unittest.main() find and run doc_test_suite > >>together with the other test suites? I only recently began using unittest, so I only know a little about it. There are almost certainly more clever ways to what you want, but wha

Convert unicode escape sequences to unicode in a file

2011-01-11 Thread Jeremy
I have a file that has unicode escape sequences, i.e., J\u00e9r\u00f4me and I want to replace all of them in a file and write the results to a new file. The simple script I've created is copied below. However, I am getting the following error: UnicodeEncodeError: 'ascii' codec can't encode

Re: Ideas for a module to process command line arguments

2011-01-11 Thread Mike
On Jan 11, 11:26 am, Michele Simionato wrote: > > In that case easy_install/pip/whatever will install the dependency > automatically (who is installing > dependencies by hand nowadays?). More seriously I thought being based I do. Is this bad? :} -- http://mail.python.org/mailman/listinfo/python-

Re: "socket operation on non socket" on Windows

2011-01-11 Thread wiz1024 wiz1024
2011/1/11 Terry Reedy > On 1/11/2011 6:18 AM, wiz1024 wiz1024 wrote: > >> Hi >> >> I have a problem on Windows with the module urllib2 with python 2.5 >> >> when i use the "urlopen" function, i have some time the following error : >> error >> >> I don't understand why suddenly this error arrives

Re: "socket operation on non socket" on Windows

2011-01-11 Thread Terry Reedy
On 1/11/2011 6:18 AM, wiz1024 wiz1024 wrote: Hi I have a problem on Windows with the module urllib2 with python 2.5 when i use the "urlopen" function, i have some time the following error : error I don't understand why suddenly this error arrives The urlopen function is called from a thread

Re: os.system and loggers

2011-01-11 Thread Tim
On Jan 10, 1:01 pm, Carl Banks wrote: > On Jan 10, 8:29 am, Tim wrote: > > > > > > > > > > > On Jan 7, 11:24 am, Tim wrote: > > > > hi, I'm using a 3rd-party python program that uses the python logging > > > facility and also makes calls to os.system. I'm trying to capture its > > > output to a

Re: Ideas for a module to process command line arguments

2011-01-11 Thread Michele Simionato
On Jan 11, 5:22 pm, Jean-Michel Pichavant wrote: > Michele Simionato wrote: > > On Jan 11, 4:06 pm, Alice Bevan McGregor wrote: > > >> Plac appears (from the documentation) to be written on top of argparse. > >>  :( > > > And the problem with that being what? > > ... not available to python 2.5 /

Re: Ideas for a module to process command line arguments

2011-01-11 Thread Jean-Michel Pichavant
Michele Simionato wrote: On Jan 11, 4:06 pm, Alice Bevan–McGregor wrote: Plac appears (from the documentation) to be written on top of argparse. :( And the problem with that being what? ... not available to python 2.5 / 2.6 users :) JM -- http://mail.python.org/mailman/listinfo/

Re: Ideas for a module to process command line arguments

2011-01-11 Thread Michele Simionato
On Jan 11, 4:06 pm, Alice Bevan–McGregor wrote: > Plac appears (from the documentation) to be written on top of argparse. >  :( And the problem with that being what? -- http://mail.python.org/mailman/listinfo/python-list

Re: Ideas for a module to process command line arguments

2011-01-11 Thread Alice Bevan–McGregor
On 2011-01-11 00:32:32 -0800, Michele Simionato said: It's a pity that the argument parsing modules in the standard library are so verbose that everybody is reinventing the same thing :-( It looks like you have reinvented plac: http://pypi.python.org/pypi/plac After looking into it, Plac's def

Re: Ideas for a module to process command line arguments

2011-01-11 Thread Alice Bevan–McGregor
On 2011-01-11 00:32:32 -0800, Michele Simionato said: On Jan 11, 8:25 am, Alice Bevan–McGregor wrote: I got tired of using PasteScript and OptParse.  Mostly OptParse, actually.  :/ It's a pity that the argument parsing modules in the standard library are so verbose that everybody is reinvent

Re: String to char and decimal number conversion

2011-01-11 Thread Stefan Behnel
SANKAR ., 11.01.2011 01:00: I am reading a Test.txt (see atatchment) file using following code to get the T2: F =open('C:\Test.txt','r') T1 = F.readlines() for i in range(len(T1)): T2 = T1[i].split(',') print(T2) Take a look at the "csv" module in the standard library. Stefan

Asking for help with code? Post a minimal working example. (was: importing modules dynamicly)

2011-01-11 Thread Ben Finney
Jean-Michel Pichavant writes: > Your code is rather strange, 'modules' looks to be a list or some > iterable, and then you expect to have a 'modulename' attribute or > something... > My guess is that you pasted an approximative translation of your code > which makes it impossible de debug. To t

Re: PJL

2011-01-11 Thread loial
Thank you. I was able to send the following PJL to the printer and it worked. @PJL STMSG DISPLAY = "Hello from John" Do you have any experience handling PJL responses from the printer?...What I really want to do is get PJL information back from the printer and read it in python(or some other Unix

os.path.realpath() and os.path.abspath()

2011-01-11 Thread Jurko Gospodnetić
Hi all. os.path.realpath() documentation states that it returns a 'canonical' path. Does that infer that it returns an absolute path? I have not found seen any implementation that does not return an absolute path, but can this be counted on? Or should we use os.path.abspath(os.path.rea

"socket operation on non socket" on Windows

2011-01-11 Thread wiz1024 wiz1024
Hi I have a problem on Windows with the module urllib2 with python 2.5 when i use the "urlopen" function, i have some time the following error : error I don't understand why suddenly this error arrives The urlopen function is called from a thread Thanks in advance. -- http://mail.python.org/

Re: importing modules dynamicly

2011-01-11 Thread Jean-Michel Pichavant
dubux wrote: I am trying to import modules dynamicly from a directory (modules/) in which i have __init__.py with the __all__ variable set. Everything imports correctly and I have verified this however I am stuck on actually using my classes in the dynamicly imported modules. this bit is in my m

Re: String to char and decimal number conversion

2011-01-11 Thread Davish Bhardwaj
On Jan 11, 4:02 am, Chris Rebert wrote: > On Mon, Jan 10, 2011 at 2:44 PM, SANKAR . wrote: > > Hello There, > > >    I am from non IT field also new to python programming.Could you > > please help me to solve the following problem? > > > I have a list T1 with following format: > > > T1 = [ '

Parsing string for " "

2011-01-11 Thread Daniel da Silva
Hi, I have come across a task where I would like to scan a short 20-80 character line of text for instances of " ". Ideally could be of any tense. I know quite a bit of programming and computer science, but computational linguistics is relatively new to me. If anyone can point me in the right di

ctypes and cygwin

2011-01-11 Thread wander.lairson
Hello, I was trying to use the libusb 1.0 with cygwin environments and noticed that this library uses stdcall calling convention, but ctypes does not have WinDLL object for cygwin. As far as I know, libusb builds with stdcall calling convention on cygwin by default. My question is if ctypes should

Re: Python use growing fast

2011-01-11 Thread Octavian Rasnita
From: "Gerry Reno" On 01/10/2011 08:31 PM, Katie T wrote: On Mon, Jan 10, 2011 at 10:29 PM, John Nagle wrote: On 1/10/2011 1:02 PM, MRAB wrote: On 10/01/2011 20:29, Dan Stromberg wrote: I invite folks to check out Tiobe's Language Popularity Rankings: http://www.tiobe.com/index.php/cont

Re: Ideas for a module to process command line arguments

2011-01-11 Thread Michele Simionato
On Jan 11, 8:25 am, Alice Bevan–McGregor wrote: explicit callbacks or typecasting functions, etc. > > I got tired of using PasteScript and OptParse.  Mostly OptParse, actually.  :/ It's a pity that the argument parsing modules in the standard library are so verbose that everybody is reinventing