Re: Helloworld with Python C extension

2016-08-29 Thread Ganesh Pal
> > > > Py_BuildValue with an "s" expects a C string - that is, a pointer to > char, not just a single character. You'd need to do something like > this: > > char buf[2] = {char1, 0}; > return Py_BuildValue("s", buf); > > ChrisA Thanks Chris for the clue's it worked, I was just wondering ho

Re: PSA: Debian Stretch, apt-listchanges, and Python 3

2016-08-29 Thread Matt Ruffalo
On 2016-08-29 23:56, Chris Angelico wrote: > Up until very recently, the system Python has only been the Python 2. > (For a while, it wasn't even 2.7, but I could easily use altinstall > for that.) I have deliberately wanted to use 3.6 for ALL testing, not > just by messing with venvs or shell alia

Re: Multimeter USB output

2016-08-29 Thread Paul Rubin
Larry Hudson writes: >> with BDS-C under CP/M. Somebody remenbering this no-fp compiler from >> the dark age before PC und Linux? > I remember it well. It's what I used to initially learn C. Source code is online here: http://www.bdsoft.com/resources/bdsc.html I've looked at it a little. I do

Re: Multimeter USB output

2016-08-29 Thread Larry Hudson via Python-list
On 08/29/2016 01:54 AM, Joe wrote: [snip...] Interesting, but... The last time I did something with c, it was with BDS-C under CM/M. Somebody remenbering this no-fp compiler from the dark age before PC und Linux? I remember it well. It's what I used to initially learn C. I'm a completely sel

Re: PSA: Debian Stretch, apt-listchanges, and Python 3

2016-08-29 Thread Chris Angelico
On Tue, Aug 30, 2016 at 11:58 AM, Matt Wheeler wrote: > I think the real PSA is "don't mess with the system python(3) version". > > So you've managed to fix this issue, but what if there are others? I think > packages on Debian have a reasonable right to expect that the version of > python3 in the

Re: PSA: Debian Stretch, apt-listchanges, and Python 3

2016-08-29 Thread Matt Wheeler
I think the real PSA is "don't mess with the system python(3) version". On Mon, 29 Aug 2016 at 13:18 Chris Angelico wrote: > If, like me, you build Python 3.6 from source and make it your default > 'python3' binary, you may run into issues with the latest > apt-listchanges, which has switched to

Re: importing down in code rather than at top of file.

2016-08-29 Thread Terry Reedy
On 8/29/2016 1:57 PM, Tobiah wrote: Is it worth while to defer the import of a large module that seldom gets used in the script? import sys import os if hardly_ever_happens(): import large_module large_module.do_task() I imagine it takes a certain amount of pro

Re: importing down in code rather than at top of file.

2016-08-29 Thread Nobody
On Tue, 30 Aug 2016 04:15:05 +1000, Chris Angelico wrote: > Don't imagine; test. Testing alone isn't really good enough. There may be perfectly valid reasons to avoid the import which won't show up in anything less than the most thorough testing imaginable. Personally I wouldn't defer an import

Re: Helloworld with Python C extension

2016-08-29 Thread Stefan Behnel
Ganesh Pal schrieb am 29.08.2016 um 19:30: > I need you input on the below hello world program. I a m trying to add a > python binding which will return the character for the given index . I am > on Python 2.7 and linux > > Example : > >>> string ='helloworld' > >>> dda_hello(5) > >>> 'w' >

Re: importing down in code rather than at top of file.

2016-08-29 Thread alister
On Mon, 29 Aug 2016 10:57:22 -0700, Tobiah wrote: > Is it worth while to defer the import of a large module that seldom > gets used in the script? > > > import sys import os > > if hardly_ever_happens(): > > import large_module large_module.do_task() >

Re: importing down in code rather than at top of file.

2016-08-29 Thread Chris Angelico
On Tue, Aug 30, 2016 at 3:57 AM, Tobiah wrote: > Is it worth while to defer the import of a large module that seldom > gets used in the script? > > > import sys > import os > > if hardly_ever_happens(): > > import large_module > large_module

importing down in code rather than at top of file.

2016-08-29 Thread Tobiah
Is it worth while to defer the import of a large module that seldom gets used in the script? import sys import os if hardly_ever_happens(): import large_module large_module.do_task() I imagine it takes a certain amount

Re: Helloworld with Python C extension

2016-08-29 Thread MRAB
On 2016-08-29 18:30, Ganesh Pal wrote: Hello Team , I need you input on the below hello world program. I a m trying to add a python binding which will return the character for the given index . I am on Python 2.7 and linux Example : string ='helloworld' dda_hello(5) 'w' /* + * Hello

Re: Helloworld with Python C extension

2016-08-29 Thread Chris Angelico
On Tue, Aug 30, 2016 at 3:30 AM, Ganesh Pal wrote: > +char dda_hello(int i) > + { > + return string[i]; > + } > + > + return Py_BuildValue("s",char1); Py_BuildValue with an "s" expects a C string - that is, a pointer to char, not just a single character. You'd need to do someth

Helloworld with Python C extension

2016-08-29 Thread Ganesh Pal
Hello Team , I need you input on the below hello world program. I a m trying to add a python binding which will return the character for the given index . I am on Python 2.7 and linux Example : >> string ='helloworld' >>dda_hello(5) >> 'w' /* + * Hello world example for python bindings +

Re: Multimeter USB output

2016-08-29 Thread Rob Gaddi
Joe wrote: > The UT61B has two interfaces, a RS232C interface and this usb interface. > The RS232 interface works well with PySerial. It continously transmits 2 > .. 3 Pakets per second with 14 Bytes each. This happens unsolicited > without any command as long as the RS232C/USB button on the DM

How to get Read the Docs to generate py-modindex.html?

2016-08-29 Thread Charles Ross
Since I appear to be experiencing one of the few times that Stack Overflow hasn’t provided any quick answers to a problem (http://stackoverflow.com/questions/39197037/how-to-get-read-the-docs-to-generate-py-modindex-html

Re: Magic UTF-8/Windows-1252 encodings

2016-08-29 Thread Chris Angelico
On Tue, Aug 30, 2016 at 1:28 AM, Random832 wrote: > On Mon, Aug 29, 2016, at 11:14, Chris Angelico wrote: >> Please don't. :) This is something that belongs in the application; >> it's somewhat hacky, and I don't see any benefit to it going into the >> language. For one thing, I could well imagine

Re: Magic UTF-8/Windows-1252 encodings

2016-08-29 Thread Random832
On Mon, Aug 29, 2016, at 11:14, Chris Angelico wrote: > Please don't. :) This is something that belongs in the application; > it's somewhat hacky, and I don't see any benefit to it going into the > language. For one thing, I could well imagine making the fallback > encoding configurable (it isn't c

Re: Magic UTF-8/Windows-1252 encodings

2016-08-29 Thread Chris Angelico
On Tue, Aug 30, 2016 at 12:38 AM, Random832 wrote: > Directing this to python-list because it's really not on the topic of > the idea being discussed. > > On Mon, Aug 29, 2016, at 05:37, Chris Angelico wrote: >> Suppose I come to python-ideas and say "Hey, the MUD community would >> really benefit

Magic UTF-8/Windows-1252 encodings

2016-08-29 Thread Random832
Directing this to python-list because it's really not on the topic of the idea being discussed. On Mon, Aug 29, 2016, at 05:37, Chris Angelico wrote: > Suppose I come to python-ideas and say "Hey, the MUD community would > really benefit from a magic decoder that would use UTF-8 where > possible,

Re: What's the best way to minimize the need of run time checks?

2016-08-29 Thread BartC
On 29/08/2016 15:00, Grant Edwards wrote: On 2016-08-29, Chris Angelico wrote: On Mon, Aug 29, 2016 at 10:13 PM, BartC wrote: In C, you can write this: int x; x = 5; x = "hello"; With certain compilers (eg. gcc) you only get a warning. (And since I don't show warnings to avoid inundatio

Re: What's the best way to minimize the need of run time checks?

2016-08-29 Thread Grant Edwards
On 2016-08-29, Chris Angelico wrote: > On Mon, Aug 29, 2016 at 10:13 PM, BartC wrote: >> In C, you can write this: >> >> int x; >> >> x = 5; >> x = "hello"; >> >> With certain compilers (eg. gcc) you only get a warning. (And since >> I don't show warnings to avoid inundation, that seems to com

Re: freqz -style plot of "window design" FIR?

2016-08-29 Thread Matti Viljamaa
Since I noticed this is better suited to the SciPy Users List, I moved it there: https://mail.scipy.org/pipermail/scipy-user/2016-August/037023.html > On 29 Aug 2016, at 14:34, Matti Viljamaa wrote: > > I’m trying to design an arbitrary frequency response filter as described here: > http://www.

Re: What's the best way to minimize the need of run time checks?

2016-08-29 Thread Ben Bacarisse
Steve D'Aprano writes: > On Mon, 29 Aug 2016 10:31 pm, Chris Angelico wrote: > >> On Mon, Aug 29, 2016 at 10:13 PM, BartC wrote: >>> In C, you can write this: >>> >>> int x; >>> >>> x = 5; >>> x = "hello"; >>> >>> With certain compilers (eg. gcc) you only get a warning. (And since I >>> don't

Re: Is duck-typing misnamed?

2016-08-29 Thread breamoreboy
On Monday, August 29, 2016 at 12:08:26 PM UTC+1, Ben Finney wrote: > Michael Torrie writes: > > > Umm no, she was actually a witch. Which makes the scene even funnier. > > "Fair caught," she says at the end. > > She says [0] “It's a fair cop”, which is using the term “cop” to mean > the arrest o

Re: What's the best way to minimize the need of run time checks?

2016-08-29 Thread Chris Angelico
On Mon, Aug 29, 2016 at 10:46 PM, Steve D'Aprano wrote: > On Mon, 29 Aug 2016 10:31 pm, Chris Angelico wrote: > >> On Mon, Aug 29, 2016 at 10:13 PM, BartC wrote: >>> In C, you can write this: >>> >>> int x; >>> >>> x = 5; >>> x = "hello"; >>> >>> With certain compilers (eg. gcc) you only get a

Re: What's the best way to minimize the need of run time checks?

2016-08-29 Thread Christian Gollwitzer
Am 29.08.16 um 14:46 schrieb Steve D'Aprano: On Mon, Aug 29, 2016 at 10:13 PM, BartC wrote: In C, you can write this: int x; x = 5; x = "hello"; Let me see if I've got this straight... Bart's second assignment will allocate a block of memory at least five bytes in size, stuff the ASCII

Re: What's the best way to minimize the need of run time checks?

2016-08-29 Thread Steve D'Aprano
On Mon, 29 Aug 2016 10:31 pm, Chris Angelico wrote: > On Mon, Aug 29, 2016 at 10:13 PM, BartC wrote: >> In C, you can write this: >> >> int x; >> >> x = 5; >> x = "hello"; >> >> With certain compilers (eg. gcc) you only get a warning. (And since I >> don't show warnings to avoid inundation, th

Re: What's the best way to minimize the need of run time checks?

2016-08-29 Thread Chris Angelico
On Mon, Aug 29, 2016 at 10:13 PM, BartC wrote: > In C, you can write this: > > int x; > > x = 5; > x = "hello"; > > With certain compilers (eg. gcc) you only get a warning. (And since I don't > show warnings to avoid inundation, that seems to compile fine for me!) That's because strings, in C,

PSA: Debian Stretch, apt-listchanges, and Python 3

2016-08-29 Thread Chris Angelico
If, like me, you build Python 3.6 from source and make it your default 'python3' binary, you may run into issues with the latest apt-listchanges, which has switched to using Python 3. The symptom is an ImportError trying to "import debconf", which is available in dist-packages in the system Python,

Re: What's the best way to minimize the need of run time checks?

2016-08-29 Thread BartC
On 29/08/2016 03:43, Steve D'Aprano wrote: Your question seems to be, what happens if you follow that with an assignment to a different type? x = 5 some_code(x) x = "hello world" Will the type-checker consider that an error ("you're assigning a str to an int") or will it infer that x is the

freqz -style plot of "window design" FIR?

2016-08-29 Thread Matti Viljamaa
I’m trying to design an arbitrary frequency response filter as described here: http://www.dspguide.com/ch17/1.htm The technique is said to result in an impulse response in time domain and later in to a filter kernel. I’ve been using scipy.signal.freqz to make

Re: Is duck-typing misnamed?

2016-08-29 Thread Ben Finney
Michael Torrie writes: > Umm no, she was actually a witch. Which makes the scene even funnier. > "Fair caught," she says at the end. She says [0] “It's a fair cop”, which is using the term “cop” to mean the arrest or sentence, asserting that it's justified. Hence, the British term “copper”, me

Re: Multimeter USB output

2016-08-29 Thread Joe
Am 29.08.2016 um 10:54 schrieb Joe: it was with BDS-C under CM/M. under CP/M, of course. -- https://mail.python.org/mailman/listinfo/python-list

Re: Multimeter USB output

2016-08-29 Thread Joe
Am 28.08.2016 um 17:22 schrieb Dennis Lee Bieber: If you can read spaghetti coded C, you might want to study https://sourceforge.net/projects/ut61/ Interesting, but... The last time I did something with c, it was with BDS-C under CM/M. Somebody remenbering this no-fp compiler from the dark ag