Re: How to write replace string for object which will be substituted? [regexp]

2009-08-05 Thread ryniek
On 5 Sie, 00:55, MRAB wrote: > ryniek90 wrote: > > Hi. > > I started learning regexp, and some things goes well, but most of them > > still not. > > > I've got problem with some regexp. Better post code here: > > > " > >  >>> import re > >  >>> mail = '\nn...@mail.com\nname1 [at] mail [dot] com\nn

Re: Turtle Graphics are incompatible with gmpy

2009-08-05 Thread casevh
On Aug 4, 10:49 pm, Mensanator wrote: > I hadn't noticed this before, but the overhaul of Turtle Graphics > dating > back to 2.6 has been broken as far as gmpy is concerned. > The reason is that code in turtle.py was chabged from > > v2.5 >         if self._drawing: >             if self._tracing:

Re: Turtle Graphics are incompatible with gmpy

2009-08-05 Thread Steven D'Aprano
On Wed, 5 Aug 2009 03:49 pm Mensanator wrote: > In 3.1, tracing is now a screen attribute, not a turtle atribute. > I have no idea why > > tooter = turtle.Turtle() > tooter.tracer(False) > > doesn't give me an error (I thought silent errors were a bad thing). What makes it an error? Do you

Re: The Perils of PyContract (and Generators)

2009-08-05 Thread Steven D'Aprano
On Wed, 5 Aug 2009 03:06 pm Nick Daly wrote: > The problem actually lies in the contract. Generally, the PyContract > shouldn't affect the return values or in any way modify the code, which > it doesn't, as long as the function returns a list values (the way the > code had in fact originally been

Re: Turtle Graphics are incompatible with gmpy

2009-08-05 Thread Gregor Lingl
Mensanator schrieb: I hadn't noticed this before, but the overhaul of Turtle Graphics dating back to 2.6 has been broken as far as gmpy is concerned. I hadn't noticed because I usually have tracing turned off (tracing off takes 3-4 seconds, tracing on takes 6-7 minutes). In 3.1, tracing is now

Cypress FX2 - py libusb code?

2009-08-05 Thread RayS
I'm looking for a Python example for the FX2 USB chip (I'm using the SerMod-100 board http://www.acquiredevices.com/sermod100.jsp). Does anyone have a simple "hello" script to re-enumerate the chip, and then do control or bulk reads with only Python and libusb? I've found C code and some Python m

Re: Turtle Graphics are incompatible with gmpy

2009-08-05 Thread Gregor Lingl
Steven D'Aprano schrieb: On Wed, 5 Aug 2009 03:49 pm Mensanator wrote: In 3.1, tracing is now a screen attribute, not a turtle atribute. I have no idea why tooter = turtle.Turtle() tooter.tracer(False) doesn't give me an error (I thought silent errors were a bad thing). What makes it an

Re: merge two png pic

2009-08-05 Thread News123
You didn't really tell us why you need one big file, which contains more pixel, than you can probably store in RAM Is it for printing? Not knwoing your goal makes it difficult to suggest solutions. Can't you use other image formats like raw RGB or What other image formats are supported? tiff? Ra

Re: Using Python to automate builds

2009-08-05 Thread Hendrik van Rooyen
On Tuesday 04 August 2009 21:13:10 Kosta wrote: > I am a Python newbie, tasked with automating (researching) building > Windows drivers using the WDK build environment. I've been looking > into Python for this (instead of writing a bunch of batch files). > Why do you not use make and a makefile -

Special chars with HTMLParser

2009-08-05 Thread Fafounet
Hello, I am parsing a web page with special chars such as é (which stands for é). I know I can have the unicode character é from unicode ("\xe9","iso-8859-1") but with those extra characters I don' t know. I tried to implement handle_charref within HTMLParser without success. Furthermore, if I ha

Re: Is it possible to have the python color in the terminal ?

2009-08-05 Thread aurelien
> You might try posting to this thread: > http://groups.google.com/group/comp.lang.python/browse_thread/thread/58df7b77394e4666/f4c13766a1e09380 > I don't know much about the question myself, though. > > Marcus Thanks for your help ! aurelien -- http://mail.python.org/mailman/listinfo/pyth

trouble with complex numbers

2009-08-05 Thread Dr. Phillip M. Feldman
When I try to compute the phase of a complex number, I get an error message: In [3]: from cmath import * In [4]: x=1+1J In [5]: phase(x) NameError: name 'phase' is not defined AttributeError: 'complex' object has no attribute 'phase' Any advice will be appreciated. -- View this message in con

Re: trouble with complex numbers

2009-08-05 Thread Chris Rebert
On Tue, Aug 4, 2009 at 11:28 PM, Dr. Phillip M. Feldman wrote: > > When I try to compute the phase of a complex number, I get an error message: > > In [3]: from cmath import * > In [4]: x=1+1J > In [5]: phase(x) > > NameError: name 'phase' is not defined > > AttributeError: 'complex' object has n

Re: trouble with complex numbers

2009-08-05 Thread alex23
On Aug 5, 4:28 pm, "Dr. Phillip M. Feldman" wrote: > When I try to compute the phase of a complex number, I get an error message: > [...] > Any advice will be appreciated. 1. What version of Python are you using, and on what platform? 2. What you snipped is necessary to help debug your problem.

Launch my application if its not running

2009-08-05 Thread sanju ps
How to check whether my gui application is running or not.If its already running i have to quit my program other wise i need to launch my program. Can anybody suggest a solution to this Regards Sanju -- http://mail.python.org/mailman/listinfo/python-list

Re: Launch my application if its not running

2009-08-05 Thread Chris Rebert
On Wed, Aug 5, 2009 at 2:03 AM, sanju ps wrote: > How to check whether my gui application is running or not.If its already > running i have to quit my program other wise i need to launch my program. > Can anybody suggest a solution to this Use a lock file? http://en.wikipedia.org/wiki/Lock_file#Lo

Re: socket.inet_ntop, and pton question

2009-08-05 Thread Mahesh Poojary S
Martin-298 wrote: > > Hi > > Are these functions (inet_ntop(), inet_pton()) from the socket library > supported on Windows. > > If not is there an equivalent for them using Windows > > Ive seen mention of people creating their own in order to use them > > Appreciate the help > > ty > --

Re: trouble with complex numbers

2009-08-05 Thread Christian Heimes
Dr. Phillip M. Feldman wrote: When I try to compute the phase of a complex number, I get an error message: In [3]: from cmath import * In [4]: x=1+1J In [5]: phase(x) NameError: name 'phase' is not defined AttributeError: 'complex' object has no attribute 'phase' Any advice will be appreciate

intricated functions: how to share a variable

2009-08-05 Thread TP
Hi everybody, See the following example: # def tutu(): def toto(): print a a = 4 print a a=2 toto() tutu() ## I obtain the following error: "UnboundLocalError: local variable 'a' referenced before assignment" This is because Python looks i

Re: Overlap in python

2009-08-05 Thread Albert van der Horst
In article , Jay Bird wrote: >Hi everyone, > >I've been trying to figure out a simple algorithm on how to combine a >list of parts that have 1D locations that overlap into a non- >overlapping list. For example, here would be my input: > >part name location >a 5-9 >b

Re: intricated functions: how to share a variable

2009-08-05 Thread Diez B. Roggisch
TP wrote: > Hi everybody, > > See the following example: > > # > def tutu(): > > def toto(): > > print a > a = 4 > print a > > a=2 > toto() > > tutu() > ## > > I obtain the following error: > "UnboundLocalError: local variable 'a' referenc

Re: intricated functions: how to share a variable

2009-08-05 Thread Chris Rebert
On Wed, Aug 5, 2009 at 3:13 AM, TP wrote: > Hi everybody, > > See the following example: > > # > def tutu(): > >    def toto(): > nonlocal a #note: this requires a rather recent version of python >        print a >        a = 4 >        print a > >    a=2 >    toto() > > tutu() >

Re: Overlap in python

2009-08-05 Thread Bearophile
Albert van der Horst: >That is an algorithmic question and has little to do with Python.< Yes, but comp.lang.python isn't comp.lang.c, that kind of questions are perfectly fine here. They help keep this place from becoming boring. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python

Re: intricated functions: how to share a variable

2009-08-05 Thread Peter Otten
TP wrote: > Hi everybody, > > See the following example: > > # > def tutu(): > > def toto(): > > print a > a = 4 > print a > > a=2 > toto() > > tutu() > ## > > I obtain the following error: > "UnboundLocalError: local variable 'a' referenc

Re: intricated functions: how to share a variable

2009-08-05 Thread Bearophile
TP: > def tutu(): > >     def toto(): > >         print a >         a = 4 >         print a > >     a=2 >     toto() > > tutu() > ## > > I obtain the following error: > "UnboundLocalError: local variable 'a' referenced before assignment" > > This is because Python looks in the local context

Re: Using Python to automate builds

2009-08-05 Thread Marcus Wanner
On 8/4/2009 5:52 PM, Philip Semanchuk wrote: On Aug 4, 2009, at 5:40 PM, Kosta wrote: On Aug 4, 2:34 pm, Dave Angel wrote: + I have released pyKook 0.0.2. +http://pypi.python.org/pypi/Kook/0.0.2 +http://www.kuwata-lab.com/kook/ +http://www.kuwata-lab.com/kook/pykook-users-guide.html Other

Re: Overlap in python

2009-08-05 Thread Marcus Wanner
On 8/4/2009 6:09 PM, MRAB wrote: >>> parts = [(5, 9, "a"), (7, 10, "b"), (3, 6, "c"), (15, 20, "d"), (18, 23, "e")] >>> parts.sort() >>> parts [(3, 6, 'c'), (5, 9, 'a'), (7, 10, 'b'), (15, 20, 'd'), (18, 23, 'e')] >>> # Merge overlapping intervals. >>> pos = 1 >>> while pos < len(parts):

Re: How to write replace string for object which will be substituted? [regexp]

2009-08-05 Thread Jon Clements
On 5 Aug, 07:53, ryniek wrote: > On 5 Sie, 00:55, MRAB wrote: > > > > > ryniek90 wrote: > > > Hi. > > > I started learning regexp, and some things goes well, but most of them > > > still not. > > > > I've got problem with some regexp. Better post code here: > > > > " > > >  >>> import re > > >  >

Re: How to write replace string for object which will be substituted? [regexp]

2009-08-05 Thread Anthra Norell
MRAB wrote: ryniek90 wrote: Hi. I started learning regexp, and some things goes well, but most of them still not. I've got problem with some regexp. Better post code here: " >>> import re >>> mail = '\nn...@mail.com\nname1 [at] mail [dot] com\nname2 [$at$] mail [$dot$] com\n' >>> mail '

Re: Using Python to automate builds

2009-08-05 Thread David Cournapeau
On Wed, Aug 5, 2009 at 4:56 PM, Hendrik van Rooyen wrote: > On Tuesday 04 August 2009 21:13:10 Kosta wrote: >> I am a Python newbie, tasked with automating (researching) building >> Windows drivers using the WDK build environment.  I've been looking >> into Python for this (instead of writing a bun

Do anyone here use Python *embedded* in a database?

2009-08-05 Thread Jonathan Fine
Hi I'm writing a talk that compares embed and extend, and wondered if anyone here ever used the Python *embedded* in a database server. http://twistedmatrix.com/users/glyph/rant/extendit.html Web frameworks (such as Django) use extend, to import an extension module that makes a connection

Re: How to write replace string for object which will be substituted? [regexp]

2009-08-05 Thread ryniek
On 5 Sie, 13:28, Anthra Norell wrote: > MRAB wrote: > > ryniek90 wrote: > >> Hi. > >> I started learning regexp, and some things goes well, but most of > >> them still not. > > >> I've got problem with some regexp. Better post code here: > > >> " > >>  >>> import re > >>  >>> mail = '\nn...@mail.c

Re: How to write replace string for object which will be substituted? [regexp]

2009-08-05 Thread ryniek
On 5 Sie, 13:28, Anthra Norell wrote: > MRAB wrote: > > ryniek90 wrote: > >> Hi. > >> I started learning regexp, and some things goes well, but most of > >> them still not. > > >> I've got problem with some regexp. Better post code here: > > >> " > >>  >>> import re > >>  >>> mail = '\nn...@mail.c

Re: Special chars with HTMLParser

2009-08-05 Thread Piet van Oostrum
> Fafounet (F) wrote: >F> Hello, >F> I am parsing a web page with special chars such as é (which >F> stands for é). >F> I know I can have the unicode character é from unicode >F> ("\xe9","iso-8859-1") >F> but with those extra characters I don' t know. >F> I tried to implement handle_charref

Re: trouble with complex numbers

2009-08-05 Thread Piet van Oostrum
> Christian Heimes (CH) wrote: >CH> You can write your own phase() function. This function is mostly correct >CH> unless either the real and/or the imag part is NaN or INF. >CH> from math import atan2 >CH> def phase(z): >CH> z += 1j # convert int, long, float to complex That should be

Re: intricated functions: how to share a variable

2009-08-05 Thread TP
Bearophile wrote: > So probably a better solution is to just use the normal function > semantics: you pass them an argument and you take an argument as > return value. Such return value will be the new version of the value > you talk about. Thanks for your answer. Yes, it is better like this. My

Datetime with float seconds

2009-08-05 Thread kpal
Hello Everybody, The standard datetime has 1 microsecond granularity. My application needs finer time resolution, preferably float seconds. Is there an alternative to the out-of-the-box datetime? Timezone support is not essential. Thanks, -- http://mail.python.org/mailman/listinfo/python-list

Re: The Perils of PyContract (and Generators)

2009-08-05 Thread Nick Daly
On Wed, 5 Aug 2009 03:06 pm Nick Daly wrote: > The problem actually lies in the contract. Generally, the PyContract > shouldn't affect the return values or in any way modify the code, which > it doesn't, as long as the function returns a list values (the way the > code had in fact originally been

Re: Special chars with HTMLParser

2009-08-05 Thread Fafounet
Thank you, now I can get the correct character. Now when I have the string abécd I can get ab then é thanks to your function and then cd. But how is it possible to know that cd is still the same word ? Fabien > The character references indicate Unicode ordinals, not iso-8859-1 > characters. In

Re: Datetime with float seconds

2009-08-05 Thread Xavier Ho
On Wed, Aug 5, 2009 at 10:50 PM, kpal wrote: > Hello Everybody, > > The standard datetime has 1 microsecond granularity. My application > needs finer time resolution, preferably float seconds. Is there an > alternative to the out-of-the-box datetime? Timezone support is not > essential. This is

Re: intricated functions: how to share a variable

2009-08-05 Thread alex23
TP wrote: > Then, as advised Diez, perhaps the best solution is to have "true" global > variables by using a class and defining the variable a as a member self.a > of the class. By doing like this, a will be known everywhere. Or, as Bearophile suggested, you could use the standard way of passing

Re: Is this a bug in multiprocessing or in my script?

2009-08-05 Thread Jesse Noller
On Aug 5, 1:21 am, sturlamolden wrote: > On Aug 5, 4:37 am, erikcw wrote: > > > It's not always the same traceback, but they are always short like > > this.  I'm running Python 2.6.2 on Ubuntu 9.04. > > > Any idea how I can debug this? > > In my experience,multiprocessingis fragile. Scripts tend

Re: trouble with complex numbers

2009-08-05 Thread alex23
Piet van Oostrum wrote: > That should be z += 0j Pardon my ignorance, but could anyone explain the rationale behind using 'j' to indicate the imaginary number (as opposed to the more intuitive 'i')? (Not that I've had much call to use complex numbers but I'm curious) -- http://mail.python.o

Re: Announcing PythonTurtle

2009-08-05 Thread John Posner
OK, then why the statements "from turtle import *" in the modules turtleprocess.py and turtlewidget.py? Yes, I see that now (he said meekly, too sheepish to complain about being misled by an unfortunate naming choice). Tx, John -- http://mail.python.org/mailman/listinfo/python-list

Re: Turtle Graphics are incompatible with gmpy

2009-08-05 Thread casevh
On Aug 5, 12:19 am, Steven D'Aprano wrote: > On Wed, 5 Aug 2009 03:49 pm Mensanator wrote: > > > In 3.1, tracing is now a screen attribute, not a turtle atribute. > > I have no idea why > > >   tooter = turtle.Turtle() > >   tooter.tracer(False) > > > doesn't give me an error (I thought silent err

Subclassing Python's dict

2009-08-05 Thread Sergey Simonenko
Hi, I subclass builtin 'dict' in my application and experience some problems with it. The whole issue is that I should redefine 'setdefault' and 'update' methods after redefining '__setitem__' or/and '__delitem__', otherwise 'update' and 'setdefault' ignore redefined '__setitem__' and use

Re: Using Python to automate builds

2009-08-05 Thread Hendrik van Rooyen
On Wednesday 05 August 2009 14:08:18 David Cournapeau wrote: > On Wed, Aug 5, 2009 at 4:56 PM, Hendrik van > > Rooyen wrote: > > On Tuesday 04 August 2009 21:13:10 Kosta wrote: > >> I am a Python newbie, tasked with automating (researching) building > >> Windows drivers using the WDK build environm

Re: Subclassing Python's dict

2009-08-05 Thread Xavier Ho
On Thu, Aug 6, 2009 at 11:51 AM, Sergey Simonenko wrote: > I subclass builtin 'dict' in my application and experience some problems > with it. > You should subclass collections.UserDict, and not the default dict class. Refer to the collections module. Also, the ABC MutableMapping might be of you

Re: Do anyone here use Python *embedded* in a database?

2009-08-05 Thread Jon Clements
On 5 Aug, 13:17, Jonathan Fine wrote: > Hi > > I'm writing a talk that compares embed and extend, and wondered if > anyone here ever used the Python *embedded* in a database server. >      http://twistedmatrix.com/users/glyph/rant/extendit.html > > Web frameworks (such as Django) use extend, to im

Re: Subclassing Python's dict

2009-08-05 Thread Bruno Desthuilliers
Sergey Simonenko a écrit : Hi, I subclass builtin 'dict' in my application and experience some problems with it. The whole issue is that I should redefine 'setdefault' and 'update' methods after redefining '__setitem__' or/and '__delitem__', otherwise 'update' and 'setdefault' ignore redefin

http access produces 503

2009-08-05 Thread Rog
I am porting a simple code from Perl, the website asks for usr/pwd and the server's side Perl script makes atemp ftp dir for file upload. The original Perl script connects okay, does its job. The same URL stuffed into FF3 performs the same way. My Python script I am sweating out for past four days

unicode() vs. s.decode()

2009-08-05 Thread Michael Ströder
HI! These both expressions are equivalent but which is faster or should be used for any reason? u = unicode(s,'utf-8') u = s.decode('utf-8') # looks nicer Ciao, Michael. -- http://mail.python.org/mailman/listinfo/python-list

Parsing Binary Structures; Is there a better way / What is your way?

2009-08-05 Thread Martin P. Hellwig
Hi List, On several occasions I have needed (and build) a parser that reads a binary piece of data with custom structure. For example (bogus one): BE +-+-+-+-+--++ | Version | Command | Instruction | Data Length | Data | Filler | +-+-

Is it possible to produce spider plots?

2009-08-05 Thread dp_pearce
I want to be able to use Python to produce Spider plots (perhaps you know them as radar plots or star plots). Does anyone know how to achieve this? Are there existing libraries? Direction to any examples, especially those with tutorials, would be greatly appreciated. Cheers, Dan http://www.answe

Re: Overlap in python

2009-08-05 Thread nn
On Aug 5, 7:13 am, Marcus Wanner wrote: > On 8/4/2009 6:09 PM, MRAB wrote: > > >  >>> parts = [(5, 9, "a"), (7, 10, "b"), (3, 6, "c"), (15, 20, "d"), > > (18, 23, "e")] > >  >>> parts.sort() > >  >>> parts > > [(3, 6, 'c'), (5, 9, 'a'), (7, 10, 'b'), (15, 20, 'd'), (18, 23, 'e')] > >  >>> # Merge

Re: Overlap in python

2009-08-05 Thread Scott David Daniels
Jay Bird wrote: Hi everyone, I've been trying to figure out a simple algorithm on how to combine a list of parts that have 1D locations that overlap into a non- overlapping list. For example, here would be my input: part name location a 5-9 b 7-10 c

web access yields "503"

2009-08-05 Thread roger_lynx
Hi, I am porting a simple code from Perl, the website asks for usr/pwd and the server's side Perl script makes a temp ftp dir for a file upload. The original Perl script connects okay, does its job. The same URL stuffed into FF3 performs the same way. My Python script I am sweating over for past

Re: trouble with complex numbers

2009-08-05 Thread Scott David Daniels
alex23 wrote: Piet van Oostrum wrote: That should be z += 0j Pardon my ignorance, but could anyone explain the rationale behind using 'j' to indicate the imaginary number (as opposed to the more intuitive 'i')? (Not that I've had much call to use complex numbers but I'm curious) I think

error return from urlopen

2009-08-05 Thread Rustom Mody
When I direct urlopen to a non-existent server process I get IOError: [Errno socket error] (10061, 'Connection refused') The connection refused is as expected but whats the 10061? strerror(10061) says 'unknown error' So its like an errno but not quite an errno? Can I find out more about this numb

Re: Is it possible to produce spider plots?

2009-08-05 Thread Robin Becker
dp_pearce wrote: I want to be able to use Python to produce Spider plots (perhaps you know them as radar plots or star plots). Does anyone know how to achieve this? Are there existing libraries? Direction to any examples, especially those with tutorials, would be greatly appreciated. Cheers, .

Re: trouble with complex numbers

2009-08-05 Thread alex23
On Aug 6, 1:18 am, Scott David Daniels wrote: > I think it explained in the complex math area, but basically EE types > use j, math types use i for exactly the same thing.  Since i is so > frequently and index in CS, and there is another strong convention, > why not let the EE types win? That 'i'

Re: error return from urlopen

2009-08-05 Thread Albert Hopkins
On Wed, 2009-08-05 at 20:48 +0530, Rustom Mody wrote: > When I direct urlopen to a non-existent server process I get > > IOError: [Errno socket error] (10061, 'Connection refused') > The connection refused is as expected but whats the 10061? > strerror(10061) says 'unknown error' > > So its like

Re: Is it possible to produce spider plots?

2009-08-05 Thread jkn
On Aug 5, 3:51 pm, dp_pearce wrote: > I want to be able to use Python to produce Spider plots (perhaps you > know them as radar plots or star plots). Does anyone know how to > achieve this? Are there existing libraries? > The 'wxPython in Action' book has some simple example code which produces t

Re: intricated functions: how to share a variable

2009-08-05 Thread Jason Tackaberry
On Wed, 2009-08-05 at 12:39 +0200, Diez B. Roggisch wrote: > Another often used trick is to have a mutable container-object, like this: > > def tutu(): >a = [2] > >def toto(): >a[0] = 4 > >toto() When you need a writable bound variable inside a closure, I prefer this idi

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-05 Thread Jon Clements
On 5 Aug, 15:46, "Martin P. Hellwig" wrote: > Hi List, > > On several occasions I have needed (and build) a parser that reads a > binary piece of data with custom structure. For example (bogus one): > > BE > +-+-+-+-+--++ > | Version | Command |

Re: Using Python to automate builds

2009-08-05 Thread Kosta
On Aug 5, 7:29 am, Hendrik van Rooyen wrote: > On Wednesday 05 August 2009 14:08:18 David Cournapeau wrote: > > > On Wed, Aug 5, 2009 at 4:56 PM, Hendrik van > > > Rooyen wrote: > > > On Tuesday 04 August 2009 21:13:10 Kosta wrote: > > >> I am a Python newbie, tasked with automating (researching)

Re: Overlap in python

2009-08-05 Thread Mark Lawrence
Jay Bird wrote: Hi everyone, I wanted to thank you all for your help and *excellent* discussion. I was able to utilize and embed the script by Grigor Lingl in the 6th post of this discussion to get my program to work very quickly (I had to do about 20 comparisons per data bin, with over 40K bin

Re: unicode() vs. s.decode()

2009-08-05 Thread Jason Tackaberry
On Wed, 2009-08-05 at 16:43 +0200, Michael Ströder wrote: > These both expressions are equivalent but which is faster or should be used > for any reason? > > u = unicode(s,'utf-8') > > u = s.decode('utf-8') # looks nicer It is sometimes non-obvious which constructs are faster than others in Pytho

Re: Do anyone here use Python *embedded* in a database?

2009-08-05 Thread Jonathan Fine
Jon Clements wrote: On 5 Aug, 13:17, Jonathan Fine wrote: Hi I'm writing a talk that compares embed and extend, and wondered if anyone here ever used the Python *embedded* in a database server. http://twistedmatrix.com/users/glyph/rant/extendit.html Web frameworks (such as Django) use ex

Re: Cypress FX2 - py libusb code?

2009-08-05 Thread RayS
Reply to self: code attached. As Marco wrote: "To run the single C file USB bulk read program properly, you must provide a source of data to the CY7C68013 FIFO bus, like the Simple dual channel A/D system, otherwise the reading call will time out in one second, you will get a bunch of zeros, and

Re: Is it possible to produce spider plots?

2009-08-05 Thread Mark Lawrence
dp_pearce wrote: I want to be able to use Python to produce Spider plots (perhaps you know them as radar plots or star plots). Does anyone know how to achieve this? Are there existing libraries? Direction to any examples, especially those with tutorials, would be greatly appreciated. Cheers, Da

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-05 Thread Martin P. Hellwig
Jon Clements wrote: IIRC (and I have my doubts) the BitVector module may be of use, but it's been about 3 years since I had to look at it. I think it used the C equiv. of short ints to do its work. Otherwise, maybe the array module, the struct module or even possibly ctypes. Not much use, but m

access string data from within cython

2009-08-05 Thread Diez B. Roggisch
Hi, I'm trying to wrap a C-API which has a call that takes a void* and a size_t as arguments. void foo(void *data, size_t length) The wrapper is supposed to be called with a python (byte)string instance, which might contain more than one '\0'-character. So how do I access the raw data of a str

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-05 Thread Bearophile
Martin P. Hellwig: > On several occasions I have needed (and build) a parser that reads a > binary piece of data with custom structure. For example (bogus one): > > BE > +-+-+-+-+--++ > | Version | Command | Instruction | Data Length | Data | Fill

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-05 Thread Masklinn
On 5 Aug 2009, at 16:46 , Martin P. Hellwig wrote: Hi List, On several occasions I have needed (and build) a parser that reads a binary piece of data with custom structure. For example (bogus one): BE +-+-+-+-+--++ | Version | Command | Ins

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-05 Thread Masklinn
On 5 Aug 2009, at 19:17 , Bearophile wrote: Have you tried Hachoir? (I think its name may be changed to Fusil, I don't know). Name hasn't been changed (I think fusil is a subproject, something like that) on the other hand the hachoir.org site is dead. But apparently Hachoir was moved to bitbu

Re: Turtle Graphics are incompatible with gmpy

2009-08-05 Thread Mensanator
> It didn't form 2.5 to 2.6 (at least not intentionally). But with the > indroduction of the TurtleScreen class and the Screen class/object > (singleton) a few of the turtle methods were also implemented as screen > methods and as turtle methods declared deprecated (see docs of Python > 2.6). These

Re: Turtle Graphics are incompatible with gmpy

2009-08-05 Thread Gregor Lingl
Mensanator schrieb: It didn't form 2.5 to 2.6 (at least not intentionally). But with the indroduction of the TurtleScreen class and the Screen class/object (singleton) a few of the turtle methods were also implemented as screen methods and as turtle methods declared deprecated (see docs of Python

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-05 Thread Paul Rubin
"Martin P. Hellwig" writes: > what I usually do is read the packet in binary mode, convert the > output to a concatenated 'binary string'(i.e. '0101011000110') and Something wrong with reading the data words as an integer and using old fashioned shifts and masks to get at the bit fields? -- http

Re: unicode() vs. s.decode()

2009-08-05 Thread 1x7y2z9
unicode() has LOAD_GLOBAL which s.decode() does not. Is it generally the case that LOAD_ATTR is slower than LOAD_GLOBAL that lead to your intuition that the former would probably be slower? Or some other intuition? Of course, the results from timeit are a different thing - I ask about the intuiti

Re: Special chars with HTMLParser

2009-08-05 Thread Piet van Oostrum
> Fafounet (F) wrote: >F> Thank you, now I can get the correct character. >F> Now when I have the string abécd I can get ab then é thanks to >F> your function and then cd. But how is it possible to know that cd is >F> still the same word ? That depends on your definition of `word'. And that

Re: Is it possible to produce spider plots?

2009-08-05 Thread Devon_Dan
> reportlab has a spider chart in reportlab/graphics/charts/spider.py > How about > http://matplotlib.sourceforge.net/examples/api/radar_chart.html?highl... Both exactly what I was after. Thanks very much. > The 'wxPython in Action' book has some simple example code which > produces this sort o

Re: access string data from within cython

2009-08-05 Thread Philip Semanchuk
On Aug 5, 2009, at 1:16 PM, Diez B. Roggisch wrote: Hi, I'm trying to wrap a C-API which has a call that takes a void* and a size_t as arguments. void foo(void *data, size_t length) The wrapper is supposed to be called with a python (byte)string instance, which might contain more than

Install setup tools for 2.6

2009-08-05 Thread Jeremy Cowles
Ok, I feel like this is a really stupid question, but how do you install setup tools for Python 2.6 under windows? The only format is .egg which requires setup tools to install, doesn't it? Thanks, Jeremy -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-05 Thread Martin P. Hellwig
Paul Rubin wrote: "Martin P. Hellwig" writes: what I usually do is read the packet in binary mode, convert the output to a concatenated 'binary string'(i.e. '0101011000110') and Something wrong with reading the data words as an integer and using old fashioned shifts and masks to get at the bi

Re: Confessions of a Python fanboy

2009-08-05 Thread Just Another Victim of the Ambient Morality
"Steven D'Aprano" wrote in message news:pan.2009.08.04.09.28...@remove.this.cybersource.com.au... > On Tue, 04 Aug 2009 10:03:53 +0200, Bruno Desthuilliers wrote: > >>> Disadvantages: your code is filled with line noise. It's an arbitrary >>> choice between @@ meaning instance attribute and @@ m

Re: trouble with complex numbers

2009-08-05 Thread pdlemper
On Wed, 05 Aug 2009 08:18:55 -0700, Scott David Daniels wrote: >I think it explained in the complex math area, but basically EE types >use j, math types use i for exactly the same thing. Since i is so >frequently and index in CS, and there is another strong convention, >why not let the EE types

Re: Subclassing Python's dict

2009-08-05 Thread Joshua Kugler
Xavier Ho wrote: > On Thu, Aug 6, 2009 at 11:51 AM, Sergey Simonenko > wrote: > >> I subclass builtin 'dict' in my application and experience some problems >> with it. >> > > You should subclass collections.UserDict, and not the default dict class. > Refer to the collections module. Are you ref

Re: access string data from within cython

2009-08-05 Thread sturlamolden
On 5 Aug, 19:16, "Diez B. Roggisch" wrote: > void foo(void *data, size_t length) > > The wrapper is supposed to be called with a python (byte)string instance, > which might contain more than one '\0'-character. > > So how do I access the raw data of a string? cdef extern void foo(void *data, int

Re: access string data from within cython

2009-08-05 Thread sturlamolden
On 5 Aug, 21:23, sturlamolden wrote: > foo(data, length) Oops, that would be foo( data, length) -- http://mail.python.org/mailman/listinfo/python-list

Re: Do anyone here use Python *embedded* in a database?

2009-08-05 Thread Joshua Kugler
Jonathan Fine wrote: > Hi > > I'm writing a talk that compares embed and extend, and wondered if > anyone here ever used the Python *embedded* in a database server. > http://twistedmatrix.com/users/glyph/rant/extendit.html > > Web frameworks (such as Django) use extend, to import an extensi

Re: Turtle Graphics are incompatible with gmpy

2009-08-05 Thread Mensanator
On Aug 5, 2:19 am, Steven D'Aprano wrote: > On Wed, 5 Aug 2009 03:49 pm Mensanator wrote: > > > In 3.1, tracing is now a screen attribute, not a turtle atribute. > > I have no idea why > > >   tooter = turtle.Turtle() > >   tooter.tracer(False) > > > doesn't give me an error (I thought silent erro

Re: Is this a bug in multiprocessing or in my script?

2009-08-05 Thread sturlamolden
On 5 Aug, 15:40, Jesse Noller wrote: > Sturla; > > That bug was fixed unless I'm missing something. It is still in SVN. Change every call to os._exit to sys.exit please. :) http://svn.python.org/view/python/branches/release26-maint/Lib/multiprocessing/forking.py?revision=66717&view=markup http

Re: Is this a bug in multiprocessing or in my script?

2009-08-05 Thread sturlamolden
On 5 Aug, 21:36, sturlamolden wrote: > http://svn.python.org/view/python/branches/release26-maint/Lib/multip... > > http://svn.python.org/view/python/branches/release31-maint/Lib/multip... http://svn.python.org/view/python/trunk/Lib/multiprocessing/forking.py?revision=65864&view=markup -- http

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-05 Thread Martin P. Hellwig
Paul Rubin wrote: "Martin P. Hellwig" writes: Is there an advantage using shifts and masks over my kitchen type solution? Weren't you complaining about the 8-to-1 expansion from turning each bit to an ascii char? Yes you are (of course) right, my 'dream' solution would be something that ac

Re: Is this a bug in multiprocessing or in my script?

2009-08-05 Thread ryles
On Aug 4, 10:37 pm, erikcw wrote: > Traceback (most recent call last): >   File "scraper.py", line 144, in >     print pool.map(scrape, range(10)) >   File "/usr/lib/python2.6/multiprocessing/pool.py", line 148, in map >     return self.map_async(func, iterable, chunksize).get() >   File "/usr/li

Re: no-clobber dicts?

2009-08-05 Thread kj
In <00027aa9$0$2969$c3e8...@news.astraweb.com> Steven D'Aprano writes: >No problem. Here you go: >http://www.cybersource.com.au/users/steve/python/constants.py Extremely helpful. Thanks! kynn -- http://mail.python.org/mailman/listinfo/python-list

Re: Turtle Graphics are incompatible with gmpy

2009-08-05 Thread Wolfram Hinderer
On 5 Aug., 21:31, Mensanator wrote: > > >>> import turtle > >>> tooter = turtle.Turtle() > >>> tooter.tracer > > Traceback (most recent call last): >   File "", line 1, in >     tooter.tracer > AttributeError: 'Turtle' object has no attribute 'tracer'>>> > tooter.hideturtle() > >>> tooter.speed(

Re: Is this a bug in multiprocessing or in my script?

2009-08-05 Thread Piet van Oostrum
> sturlamolden (s) wrote: >s> On 5 Aug, 15:40, Jesse Noller wrote: >>> Sturla; >>> >>> That bug was fixed unless I'm missing something. >s> It is still in SVN. Change every call to os._exit to sys.exit >s> please. :) Calling os.exit in a child process may be dangerous. It can cause unflus

How to combine regexps?

2009-08-05 Thread kj
One of the nice things one can do with Perl's regexp's is illustrated in the following example: my $gly = qr/gg[ucag]/i my $ala = qr/gc[ucag]/i; my $val = qr/gu[ucag]/i; my $leu = qr/uu[ag]|cu[ucag]/i; my $ile = qr/au[uca]/i; my $aliphatic = qr/$gly|$ala|$val|$leu|$ile/; In other words, one c

  1   2   >