updating local()
Hi, I heard time and again that you are not _supposed_ to update the locals dictionary. Can anyone tell me why, if the following code works, I should not do this? # # Extending Local namespace # def fun(a=1,b=2,**args): print 'locals:',locals() locals().update(args) print locals() e = {'s':3,'e':4} fun(k=10,v=32,**e) thanks, Flávio -- http://mail.python.org/mailman/listinfo/python-list
Re: updating local()
Ok, I got it! Its vey insecure, and it is not guaranteed to work. Fine. Now what would you do if you wanted to pass a lot of variables (like a thousand) to a function and did not wanted the declare them in the function header? Flávio -- http://mail.python.org/mailman/listinfo/python-list
Re: updating local()
I wish all my problems involved just a couple of variables, but unfortunately the real interesting problems tend to be complex... As a last resort this problem could be solved by something like this: def fun(**kw): a = 100 for k,v in kw.items(): exec('%s = %s'%(k,v)) print locals() >>> fun(**{'a':1,'b':2}) {'a': 1, 'k': 'b', 'b': 2, 'kw': {'a': 1, 'b': 2}, 'v': 2} But that would be utterly stupid! So much for not being able to write to locals() any better Ideas? -- http://mail.python.org/mailman/listinfo/python-list
Re: updating local()
Ok, its not thousands, but more like dozens of variables... I am reading a large form from the web which returns a lot of values. (I am Using cherrypy) I know I could pass these variables around as: def some_function(**variables): ... some_function(**variables) but its a pain in the neck to have to refer to them as variables['whatever']... dont you think? Flavio -- http://mail.python.org/mailman/listinfo/python-list
importing a method
hi, I have an object defined with a number of hardcoded methods. Class soandso: def __init__(self): self.this = 0 self.that = 1 def meth1(self): ... def meth2(self): ... def custom(self): pass I want to allow the user to write a python module that declares a function so that myprogram can import it and attribute it to the custom method of the soandso object. So far so good, that is an easy thing to do in Python. import usermodule a=soandso() a.custom = usermodule.function But, what if the method had to access the self attributes (self.this and self.that) of the soandso object? Can it be done? and if so, what is the most Pythonic way of doing it? thanks in advance, Flávio -- http://mail.python.org/mailman/listinfo/python-list
Re: importing a method
Because, by the time the user function is imported and attributed to the custom method, soandso has already been instantiated and contains the information tha needs to accessed by the user's function. -- http://mail.python.org/mailman/listinfo/python-list
Re: importing a method
If you read my original post, I had no intention of atributing the user's method to the class, but to the instance. Anyway I figure it out myself, and its quite a Pythonic solution: >>> class Foo: name='John' >>> a=Foo() >>> def p(parent): self=parent print 'Hi, %s!'%self.name >>> a.met=p >>> a.met(a) Hi, John! This works the same way an object's built-in method would work, since all methods receive a reference to the parent object through the required argument "self". class Foo: def met(self): print self Thanks for all the replies, they helped to catalize my own thoughts! Flávio -- http://mail.python.org/mailman/listinfo/python-list
Re: importing a method
There only one puzzle left to solve: altough the solution I proposed works, this variant has problems: >>> class Foo: name='John' >>> a=Foo() >>> def p(): print 'Hi, %s!'%self.name >>> a.met=p >>> a.met.self = a >>>a.met() NameError: global name 'self' is not defined This error is paradoxical since: >>> a.met.self <__main__.Foo instance at 0x405ed2ec> Can anyone explain this? -- http://mail.python.org/mailman/listinfo/python-list
Re: importing a method
This "new" module sounds pretty cool, too bad its deprecated... I would not want to add a dependancy to a deprecated module in my code. But maybe I'll check the code for instancemethod within it and see what it does. Flávio -- http://mail.python.org/mailman/listinfo/python-list
Re: importing a method
Addendum to my last reply: although the New Method is deprecated, new.instancemethod (from Antoon's message) can be replaced by from types import MethodType f.show = MethodType(show,f) and every thing still works. -- http://mail.python.org/mailman/listinfo/python-list
Re: importing a method
> First of all,why do you think the new module is deprecated? (I can't > find anything in the docs to indicate this.) Its in the docs of python 2.4. I dont know about older versions: Help on module new: NAME new - Create new objects of various types. Deprecated. FILE /usr/lib/python2.4/new.py MODULE DOCS /usr/share/doc/python-docs-2.4.2/html/module-new.html DESCRIPTION This module is no longer required except for backward compatibility. Objects of most types can now be created by calling the type object. > As for using MethodType in the types module: There's nothing in the > module documentation that suggests that you can call MethodType as a > function as you suggest, only that it is the name of the type of > methods of user-defined class instances.. So, while calling it might > work, it sounds like you are using an undocumented feature... If you look at new.py, all it does is import the functions from types and rename them. For MethodType is goes like this from types import MethodType as instancemethod so instance method *is* Methodtype. Moreover, I tried and it works ;-) So this solution is perfect once adapted not to depend on "new". Thanks, Flávio -- http://mail.python.org/mailman/listinfo/python-list
Re: importing a method
> If you have a function f and want to make an instancemethod out of it, > you can simply call f.__get__(theinstance, theclass) and that will build > and return the new instancemethod you require. I think that f.show = MethodType(show,f) is less cryptic than f.__get__(instance, class) Flávio -- http://mail.python.org/mailman/listinfo/python-list
can't destroy a wxMiniFrame
Hi, I have a miniframe composed mainly of combo boxes, that I need to destroy and recreate multiple time with different choice lists for the combo boxes. My problem is that even after destroying a miniframe with the Destroy() method, when it is recreated, the combo boxes show the same lists of its previous incarnation... how can I completely destroy a miniframe? Flavio -- http://mail.python.org/mailman/listinfo/python-list
Re: can't destroy a wxMiniFrame
It was human error... I found the bug... thanks, Laszlo Nagy wrote: > Flavio írta: > > Hi, > > > > I have a miniframe composed mainly of combo boxes, that I need to > > destroy and recreate multiple time with different choice lists for the > > combo boxes. > > > > My problem is that even after destroying a miniframe with the Destroy() > > method, when it is recreated, the combo boxes show the same lists of > > its previous incarnation... > > > > how can I completely destroy a miniframe? > > > From what you wrote, I think that you did not create a new miniframe. > Although you called Destroy(), you tried to display it again. This is > what the documentation says about destroy. > > Destroys the window safely. Use this function instead of the delete > operator, since different window classes can be destroyed differently. > *Frames and dialogs are not destroyed immediately* when this function is > called -- they are added to a list of windows to be deleted on idle > time, when all the window's events have been processed. This prevents > problems with events being sent to non-existent windows. > > > Regards, > >Laszlo -- http://mail.python.org/mailman/listinfo/python-list
xmingw and f2py
Hi, has anyone tried to build extensions for win32 on Linux using xmingw? I need to use f2py to compile code for the win32 platform and I want to do this in Linux. I googled aroung but could not find any documentation on this. For those who dont know xmingw is a port to linux of mingw. any help is appreciated. Flávio -- http://mail.python.org/mailman/listinfo/python-list
Re: xmingw and f2py
Flavio wrote: > Hi, > > has anyone tried to build extensions for win32 on Linux using xmingw? > > I need to use f2py to compile code for the win32 platform and I want to > do this in Linux. I googled aroung but could not find any documentation > on this. > > For those who dont know xmingw is a port to linux of mingw. > > any help is appreciated. > > Flávio Since no one has responded so far, I decide to put some more data in this thread to encourage some comments. I have tried to compile the fortran code with the following line: f2py -c --compiler=/opt/xmingw/bin/i386-mingw32msvc-gcc --f77exec=opt/xmingw/bin/i386-mingw32msvc-g77 -m flib flib.f the error I get is like so: error: don't know how to compile C/C++ code on platform 'posix' with '/opt/xmingw/bin/i386-mingw32msvc-gcc' compiler any comments? Flávio -- http://mail.python.org/mailman/listinfo/python-list
Re: xmingw and f2py
Thanks Nick, It seems that xmingw package in gentoo is the same as the mingw on debian, from the directory structure and executables you mention. I'll give it a try and if works with f2py, I'll post a complete tutorial after I am done for other people to follow. Thanks a lot. Nick Craig-Wood wrote: > Flavio <[EMAIL PROTECTED]> wrote: > > has anyone tried to build extensions for win32 on Linux using > > xmingw? > > I don't know about xmingw, but we use mingw on linux to compile stuff > for windows all the time. (We use the mingw package under debian) > > We build extensions using mingw but linked to the link library of the > official python2.4 build. > > Here are some instructions which you'll need to adapt to your setup > > /misc/windows is a smb mounted windows machine > > # Linking with the distributed python > # > # http://bonsai.ims.u-tokyo.ac.jp/~mdehoon/software/python/cygwin.html > # > # On a windows machine > # install the latest windows python (2.4.3.msi) from www.python.org > # Copy the header files into the mingw installation > cp -av /misc/windows/Python24/include /usr/i586-mingw32msvc/include/python2.4 > # Download pexports from here > # > http://www.emmestech.com/software/cygwin/pexports-0.43/download_pexports.html > # unpack pexports.exe > unzip pexports-0.43.zip > # Fetch python dll from the windows machine > cp -av /misc/windows/WINNT/system32/python24.dll . > # Extract the exported symbols > wine pexports python24.dll > python24.def > # Create the link library > /usr/i586-mingw32msvc/bin/dlltool --dllname python24.dll --def python24.def > --output-lib libpython2.4.a > # Move the files into the correct place > mv -i python24.dll python24.def libpython2.4.a /usr/i586-mingw32msvc/lib/ > > After that lot you can build python extensions with mingw under linux, > using -lpython2.4 > > -- > Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: xmingw and f2py
Hi Nick, I followed the steps you describe exactly and I am still gettin this error message when i try to compile. here is the command I give: f2py -c --compiler=/opt/xmingw/bin/i386-mingw32msvc-gcc --f77exec=opt/xmingw/bi n/i386-mingw32msvc-g77 -L /opt/xmingw/i386-mingw32msvc/lib/ -lpython2.4 -m flib flib.f and this is the error: copying /usr/lib/python2.4/site-packages/numpy-1.0b5-py2.4-linux-i686.egg/numpy/f2py/src/fortranobject.c -> /tmp/tmpIkxhAr/src.linux-i686-2.4 copying /usr/lib/python2.4/site-packages/numpy-1.0b5-py2.4-linux-i686.egg/numpy/f2py/src/fortranobject.h -> /tmp/tmpIkxhAr/src.linux-i686-2.4 adding '/tmp/tmpIkxhAr/src.linux-i686-2.4/flib-f2pywrappers.f' to sources. running build_ext error: don't know how to compile C/C++ code on platform 'posix' with '/opt/xmingw/bin/i386-mingw32msvc-gcc' compiler any further suggestions? Nick Craig-Wood wrote: > Flavio <[EMAIL PROTECTED]> wrote: > > has anyone tried to build extensions for win32 on Linux using > > xmingw? > > I don't know about xmingw, but we use mingw on linux to compile stuff > for windows all the time. (We use the mingw package under debian) > > We build extensions using mingw but linked to the link library of the > official python2.4 build. > > Here are some instructions which you'll need to adapt to your setup > > /misc/windows is a smb mounted windows machine > > # Linking with the distributed python > # > # http://bonsai.ims.u-tokyo.ac.jp/~mdehoon/software/python/cygwin.html > # > # On a windows machine > # install the latest windows python (2.4.3.msi) from www.python.org > # Copy the header files into the mingw installation > cp -av /misc/windows/Python24/include /usr/i586-mingw32msvc/include/python2.4 > # Download pexports from here > # > http://www.emmestech.com/software/cygwin/pexports-0.43/download_pexports.html > # unpack pexports.exe > unzip pexports-0.43.zip > # Fetch python dll from the windows machine > cp -av /misc/windows/WINNT/system32/python24.dll . > # Extract the exported symbols > wine pexports python24.dll > python24.def > # Create the link library > /usr/i586-mingw32msvc/bin/dlltool --dllname python24.dll --def python24.def > --output-lib libpython2.4.a > # Move the files into the correct place > mv -i python24.dll python24.def libpython2.4.a /usr/i586-mingw32msvc/lib/ > > After that lot you can build python extensions with mingw under linux, > using -lpython2.4 > > -- > Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
f2py on windows tutorials
Hello, Compiling f2py extensions in Linux is a trivial task, You can even automate it with distutils. Now, in a Windows machine this does not seem to be an easy task. At least, I could not find any decent tutorial on how to do it. Is there a way to do this? Can some one point me to a tutorial., please? I have tried some approaches: mingw, xmingw (cross-compiling from Linux) and Python enthought edition (which is supposed to come preconfigured to enable people to use Scipy tools, such as f2py) Withouth success. Anyone out there knows how to do this? Anyone from the Scipy dev team care to document it? Flávio -- http://mail.python.org/mailman/listinfo/python-list
Re: f2py on windows tutorials
Its been a while since i Tried this and right now I have no access to a windows machine to try it and show you the error messages I was getting. I was using the latest version of Python Enthouhgt edition. But I was trying to compile the fortran code directly with f2py. What I would like to have is a setup.py tailored to compile an f2py extension on windows. Have you got one of these? if so please send it to me and I can certainly figure out the rest. thanks, Flavio Robert Kern wrote: > Flavio wrote: > > Hello, > > > > Compiling f2py extensions in Linux is a trivial task, You can even > > automate it with distutils. Now, in a Windows machine this does not > > seem to be an easy task. At least, I could not find any decent tutorial > > on how to do it. > > > > Is there a way to do this? Can some one point me to a tutorial., > > please? > > > > I have tried some approaches: mingw, xmingw (cross-compiling from > > Linux) and Python enthought edition (which is supposed to come > > preconfigured to enable people to use Scipy tools, such as f2py) > > Withouth success. > > > > Anyone out there knows how to do this? Anyone from the Scipy dev team > > care to document it? > > It's worked fine for me using Enthon (which comes with mingw and g77, > things you will need at minimum). > > What versions of Enthon and f2py are you using? > What exactly did you try? > What errors are you seeing? > How are you trying to compile your modules, i.e. with just the f2py command or > are you building a setup.py file? > Did you pass "--compiler=mingw --fcompiler=gnu" to your build command? > > -- > Robert Kern > > "I have come to believe that the whole world is an enigma, a harmless enigma > that is made terrible by our own mad attempt to interpret it as though it > had > an underlying truth." >-- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: f2py on windows tutorials
Thank you Robert, I was surprised that the setup.py was virtually identical to the one I use for Linux. However I was not at all surprised when it didn't work. ;-) It complains it can't find msvc: No module named msvccompiler in numpy.distutils, trying from distutils.. error: the .NET Framework SDK needs to be installed before building extensions for Python. any further help will be greatly appreciated... Thanks again, Flávio Robert Kern wrote: > Flavio wrote: > > Its been a while since i Tried this and right now I have no access to a > > windows > > machine to try it and show you the error messages I was getting. > > > > I was using the latest version of Python Enthouhgt edition. But I was > > trying to compile the fortran code directly with f2py. > > > > What I would like to have is a setup.py tailored to compile an f2py > > extension on windows. Have you got one of these? if so please send it > > to me and I can certainly figure out the rest. > > > from numpy.distutils.core import setup, Extension > > setup(name='something', >ext_modules=[Extension('my_subroutines', > sources=['wrapper.pyf', 'lib1.f', 'lib2.f'], > )], > ) > > -- > Robert Kern > > "I have come to believe that the whole world is an enigma, a harmless enigma > that is made terrible by our own mad attempt to interpret it as though it > had > an underlying truth." >-- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: f2py on windows tutorials
Ok, I tried that and it seems we are making progress so here is my command: python setup.py build_ext --compiler=mingw32 --fcompiler=gnu Now it is complaining about my pyf!! error: unknown file type '.pyf' here is my setup .py: import setuptools, os from numpy.distutils.core import setup, Extension #Configuring Build libs=[];libdirs=[];f2pyopts=[] if os.name == 'nt': f2pyopts.extend(["--compiler=mingw32","--fcompiler=gnu"]) flib = Extension(name='flib', libraries=libs, library_dirs=libdirs, f2py_options=f2pyopts, sources=['model-builder/Bayes/flib.f','model-builder/Bayes/flib.pyf',] ) etc... > > More specifically: > >python setup.py build_ext --compiler=mingw --fcompiler=gnu > > -- > Robert Kern > > "I have come to believe that the whole world is an enigma, a harmless enigma > that is made terrible by our own mad attempt to interpret it as though it > had > an underlying truth." >-- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: f2py on windows tutorials
Hi Robert, Putting the .pyf first didn't do any good. I still get the same error message of unknown file type However when I try to compile with f2py, all works perfectly! here is the command I used: f2py -c flib.pyf flib.f --compiler=mingw32 --fcompiler=gnu Note: if I use mingw instead of mingw32 it does not work!! So all that remains now is to be able to do it from the setup.py... thanks again... Robert Kern wrote: > Flavio wrote: > > Ok, > > > > I tried that and it seems we are making progress > > > > so here is my command: > > > > python setup.py build_ext --compiler=mingw32 --fcompiler=gnu > > > > Now it is complaining about my pyf!! > > > > error: unknown file type '.pyf' > > > > here is my setup .py: > > > > import setuptools, os > > from numpy.distutils.core import setup, Extension > > > > #Configuring Build > > libs=[];libdirs=[];f2pyopts=[] > > if os.name == 'nt': > > f2pyopts.extend(["--compiler=mingw32","--fcompiler=gnu"]) > > These don't belong here. If you don't want to type them in at the command > line, > put them in a setup.cfg file next to your setup.py: > > > [build_ext] > compiler=mingw > fcompiler=gnu > > > (Note: "mingw", not "mingw32"!) > > > flib = Extension(name='flib', > > libraries=libs, > > library_dirs=libdirs, > > f2py_options=f2pyopts, > > > > sources=['model-builder/Bayes/flib.f','model-builder/Bayes/flib.pyf',] > > The .pyf file needs to come first. > > -- > Robert Kern > > "I have come to believe that the whole world is an enigma, a harmless enigma > that is made terrible by our own mad attempt to interpret it as though it > had > an underlying truth." >-- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: f2py on windows tutorials
Hi Robert, Good News, I tried creating the setup.cfg as you suggested and ran python setup.py bdist_wininst and python setup.py bdist_egg both of them worked perfectly!!! compiled my Fortran extension, and packed it up for distribution. I have since installed and tested and it even works! isn't this great? thanks for all the help you provided. I couldn't have done it without it. Cheers, Flávio Robert Kern wrote: > Flavio wrote: > > Ok, > > > > I tried that and it seems we are making progress > > > > so here is my command: > > > > python setup.py build_ext --compiler=mingw32 --fcompiler=gnu > > > > Now it is complaining about my pyf!! > > > > error: unknown file type '.pyf' > > > > here is my setup .py: > > > > import setuptools, os > > from numpy.distutils.core import setup, Extension > > > > #Configuring Build > > libs=[];libdirs=[];f2pyopts=[] > > if os.name == 'nt': > > f2pyopts.extend(["--compiler=mingw32","--fcompiler=gnu"]) > > These don't belong here. If you don't want to type them in at the command > line, > put them in a setup.cfg file next to your setup.py: > > > [build_ext] > compiler=mingw > fcompiler=gnu > > > (Note: "mingw", not "mingw32"!) > > > flib = Extension(name='flib', > > libraries=libs, > > library_dirs=libdirs, > > f2py_options=f2pyopts, > > > > sources=['model-builder/Bayes/flib.f','model-builder/Bayes/flib.pyf',] > > The .pyf file needs to come first. > > -- > Robert Kern > > "I have come to believe that the whole world is an enigma, a harmless enigma > that is made terrible by our own mad attempt to interpret it as though it > had > an underlying truth." >-- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
PyQt: QListView how to retrieve selected items?
Hi, I have a QListview widget that allows me to store a bunch of strings in it. This strings can be visualized, sorted, selected, etc. My Problem is that I cant find a way to get the user selected items back from it! I looked over the Qt documentation many times over but there is no method to that end. Any PyQt guru lurking around? should I try some other list widget, that has a "getSelected()"method? Is there one? any help will be appreciated. Flavio -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt: QListView how to retrieve selected items?
Iterating over the items and checking if it is selected, sounds like a good idea, but there no obvious way to get a hold of the list of items!! The only way you can get an item is if you are in single selection mode and you call selectedItem(). But I have to use multiple selection mode, for which this method does not work (it says so in the docs) The signal selectionChanged() is emitted whenever the set of selected items has changed but does not return any information regarding the items comprising the set. Also useless. > And all of this can be found within 20 seconds in the great Qt-Docs. > Especially easy with the included QAssistant, a help-browser with > indexing and whatever... The docs are really great, it's this particular widget that appear to lacking some important functionality! This is very sad. -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt: QListView how to retrieve selected items?
> Who has created these items? Obviously you, so you _can_ store the list > of selected items. well yeah, but the Idea was to let the user select(through the widget) a subset of the original list and then access that subset... > Or you use the equally well documented QListViewItemIterator to traverse > the list of items. Alright! Now you've hit the jackpot! I didn't know that class! There is no reference to it in the QListView docs! This can solve my problem (combined with isSelected()), though not as elegantly or efficiently as having direct access to the set of selected items which already exists but is not accessible... Thanks Diez! -- http://mail.python.org/mailman/listinfo/python-list
boolean operations on sets
Hi, I have been playing with set operations lately and came across a kind of surprising result given that it is not mentioned in the standard Python tutorial: with python sets, intersections and unions are supposed to be done like this: In [7]:set('casa') & set('porca') Out[7]:set(['a', 'c']) In [8]:set('casa') | set('porca') Out[8]:set(['a', 'c', 'o', 'p', 's', 'r']) and they work correctly. Now what is confusing is that if you do: In [5]:set('casa') and set('porca') Out[5]:set(['a', 'p', 'c', 'r', 'o']) In [6]:set('casa') or set('porca') Out[6]:set(['a', 'c', 's']) The results are not what you would expect from an AND or OR operation, from the mathematical point of view! aparently the "and" operation is returning the the second set, and the "or" operation is returning the first. If python developers wanted these operations to reflect the traditional (Python) truth value for data structures: False for empty data structures and True otherwise, why not return simply True or False? So My question is: Why has this been implemented in this way? I can see this confusing many newbies... -- http://mail.python.org/mailman/listinfo/python-list
raise UnicodeError, "label too long"
Hi I am havin a problem with urllib2.urlopen. I get this error when I try to pass a unicode to it. raise UnicodeError, "label too long" is this problem avoidable? no browser or programs such as wget seem to have a problem with these strings. -- http://mail.python.org/mailman/listinfo/python-list
Re: raise UnicodeError, "label too long"
What I am doing is very simple: I fetch an url (html page) parse it using BeautifulSoup, extract the links and try to open each of the links, repeating the cycle. Beautiful soup converts the html to unicode. That's why when I try to open the links extracted from the page I get this error. This is bad, since some links do contain strings with non-ascii characters. thanks, Flávio Marc 'BlackJack' Rintsch escreveu: > In <[EMAIL PROTECTED]>, Flavio wrote: > > > Hi I am havin a problem with urllib2.urlopen. > > > > I get this error when I try to pass a unicode to it. > > > > raise UnicodeError, "label too long" > > > > is this problem avoidable? no browser or programs such as wget seem to > > have a problem with these strings. > > What exactly are you doing? How does a (unicode?) string look like that > triggers this exception? > > Ciao, > Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: raise UnicodeError, "label too long"
something like this, for instance: http://.wikipedia.org/wiki/Copper%28II%29_hydroxide but even url with any non-ascii characters such as this http://.wikipedia.org/wiki/Ammonia also fail when passed to urlopen : File "/usr/lib/python2.4/encodings/idna.py", line 72, in ToASCII raise UnicodeError, "label too long" UnicodeError: label too long very strange, because I tried other unicode urls from the python console like this urllib2.urlopen(u'www.google.com') and it works normally: Martin v. Löwis escreveu: > Flavio schrieb: > > What I am doing is very simple: > > > > I fetch an url (html page) parse it using BeautifulSoup, extract the > > links and try to open each of the links, repeating the cycle. > > > > Beautiful soup converts the html to unicode. That's why when I try to > > open the links extracted from the page I get this error. > > > > This is bad, since some links do contain strings with non-ascii > > characters. > > Please try answering the exact question that Marc asked: > what is an example for unicode string that triggers the > exception? > > Regards, > Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: raise UnicodeError, "label too long"
Guys, I am sorry I wrote these messages very late at night. Naturally what came before the dot is the language defining two letter string that is usual of wikipedia urls. Something in my code is obviously gobbling that up. Thanks for pointing that out and my apologies again for not seeing this obvious bug. On Jan 25, 4:39 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On 24 Jan 2007 16:25:19 -0800, "Flavio" <[EMAIL PROTECTED]> declaimed > the following in comp.lang.python: > > > > > something like this, for instance: > >http://.wikipedia.org/wiki/Copper%28II%29_hydroxideWas there some > >text between the // and .wikipedia? As written this, > and the next one, both lock up Firefox. Take out the . and they work (or > put www before the . ). > > -- > WulfraedDennis Lee Bieber KD6MOG > [EMAIL PROTECTED] [EMAIL PROTECTED] > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support Staff: [EMAIL PROTECTED]) > HTTP://www.bestiaria.com/ -- http://mail.python.org/mailman/listinfo/python-list
gdesklets question: import problem
Hi, sorry for posting here, but the forum in the projects page is not working. Maybe there is a gdesklet developer lurking... :-) I cant import anything from a script, it gives me a runtime error. is this a bug or a feature? without being able to import from python standard library or other modules, applets are rather limited in functionality... thanks, Flávio -- http://mail.python.org/mailman/listinfo/python-list
plugin development best practices
Hi, Nowadays the addition of functionality to programs by means of plugins is very frequent. I want to know the opinions of experienced Python developers about the best practices when it comes to developing a plugin system for a Python package. Should plugins be modules in a separate package? Should there be a registry of available plugins? how would such a registry be implemented? etc. thanks, Flávio -- http://mail.python.org/mailman/listinfo/python-list
Re: is it possible to remove the ':' symbol in the end of lines starting with 'if', 'while' etc?
On Feb 22, 9:49 am, [EMAIL PROTECTED] wrote: > I don't know to which forum should I post the message > I hope someone related to the Python kernel development will read & > consider the idea > I'm (a former? meanwhile not sure) MATLAB user & it's very annoing > typing each time for example > while i: > print i > ... > instead of > while i > print i > ... > of course if all is written in a single line ':' I guess should not be > omited > > Thank you for you suggestions. > Sorry my bad English. > > WBR, Dmitrey Think on the bright side: you have to type ":" at the beginning of loop and conditional blocks, but you don't have to type "end" at the end... you are still saving two strokes... ;-)) -- http://mail.python.org/mailman/listinfo/python-list
Re: plugin development best practices
On Feb 22, 11:00 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Flavio wrote: > > Hi, > > > Nowadays the addition of functionality to programs by means of > > plugins is very frequent. > > > I want to know the opinions of experienced Python developers about the > > best practices when it comes to developing a plugin system for a > > Python package. > > > Should plugins be modules in a separate package? > > Should there be a registry of available plugins? how would such a > > registry be implemented? etc. > > There have been a gazillion discussions about this on this newsgroup/mailing > list. Searching the archives will get you to them. > > The dynamic nature of python makes a whole range of options available. > Depending on what you want to do (how are the plugins made available and so > on), one or the other might be preferable. > > One relatively current development is the usage of setuptools "entry-points" > feature, which is precisely made for discovering installed plugins: > > http://peak.telecommunity.com/DevCenter/setuptools#dynamic-discovery-... > > Diez Thanks Diez, I will search the archives. I am aware of the setuptools feature It is quite nice. But the documentation is not very clear on how to define "entry point groups" on the importing end, i.e. how to prepare a an application to accept plugins it doesn't even now exist. Flavio -- http://mail.python.org/mailman/listinfo/python-list
Re: plugin development best practices
On Feb 22, 11:01 am, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > On 22 Feb 2007 04:53:02 -0800, Flavio <[EMAIL PROTECTED]> wrote: > > >Hi, > > >Nowadays the addition of functionality to programs by means of > >plugins is very frequent. > > >I want to know the opinions of experienced Python developers about the > >best practices when it comes to developing a plugin system for a > >Python package. > > >Should plugins be modules in a separate package? > >Should there be a registry of available plugins? how would such a > >registry be implemented? etc. > > >thanks, > > Best practice may be to not develop a new plugin system. There are quite a > few available already. Most likely, at least one of them is suitable for your > application. > > Here are a couple starting points: > > http://twistedmatrix.com/projects/core/documentation/howto/plugin.html > > http://peak.telecommunity.com/DevCenter/setuptools#dynamic-discovery-... > > Jean-Paul The plugin system provided by twisted looks interesting (though not as simple as it could be, IMHO). Its main problem is that it introduces two dependencies : Twisted plugin and ZopeInterface. I think a functional plugin system could(and should) be done using only the standard library. Flávio -- http://mail.python.org/mailman/listinfo/python-list
Re: plugin development best practices
On Feb 22, 10:53 am, "Flavio" <[EMAIL PROTECTED]> wrote: > Hi, > > Nowadays the addition of functionality to programs by means of > plugins is very frequent. > > I want to know the opinions of experienced Python developers about the > best practices when it comes to developing apluginsystemfor a > Python package. > > Should plugins be modules in a separate package? > Should there be a registry of available plugins? how would such a > registry be implemented? etc. > > thanks, > > Flávio let me extend my original question with an example: Simple plugin system proposal: have a package (directory with __init__.py) called plugins where the actual plugins are modules in this directory. When the main script imports the plugins package, all plugin modules would be available as plugins.pluginA, plugins.pluginB , etc. A registry of available plugins would be available as a simple dir(plugins). code in the main script than wished to use a given plugin, would only have to look in the registry before calling any code from a given plugin. What is wrong/missing with this simple framework? I'd appreciate any comments. Flávio -- http://mail.python.org/mailman/listinfo/python-list
Re: plugin development best practices
On Feb 22, 12:36 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > Simple plugin system proposal: > > > have a package (directory with __init__.py) called plugins where the > > actual plugins are modules in this directory. > > > When the main script imports the plugins package, all plugin modules > > would be available as plugins.pluginA, plugins.pluginB , etc. > > > A registry of available plugins would be available as a simple > > dir(plugins). > > > code in the main script than wished to use a given plugin, would only > > have to look in the registry before calling any code from a given > > plugin. > > > What is wrong/missing with this simple framework? > > Nothing wrong. It's just one way of doing it. But it requires you to have > all plugins being part of one module, in one location. Depending on what > you want to do, this won't suffice. For example if your app is installed in > a system path you aren't supposed to write to - how do you install your > individual plugin? easy_install allows you to install to a folder that is > contained in the PYTHONPATH, and then you can discover entrypoints. > > But please, do as we suggested: read the past discussions. > > Depending on what _you_ actually want to accomplish, you're proposal is > enough. But don't expect it to become the "one plugin system to rule them > all"-solution. > > diez Oh, I have read all the links that have been suggested, but I am looking for the simplest possible solution. I have no intention to create the "next Plugin system" I am just trying to solve my own problem and in the process leave a record of a fruitfull discussion about plugin systems. BTW I have yet to check TRAC's plugin system. -- http://mail.python.org/mailman/listinfo/python-list
Re: plugin development best practices
On Feb 22, 12:51 pm, "Flavio" <[EMAIL PROTECTED]> wrote: > On Feb 22, 12:36 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > > > > > Simple plugin system proposal: > > > > have a package (directory with __init__.py) called plugins where the > > > actual plugins are modules in this directory. > > > > When the main script imports the plugins package, all plugin modules > > > would be available as plugins.pluginA, plugins.pluginB , etc. > > > > A registry of available plugins would be available as a simple > > > dir(plugins). > > > > code in the main script than wished to use a given plugin, would only > > > have to look in the registry before calling any code from a given > > > plugin. > > > > What is wrong/missing with this simple framework? > > > Nothing wrong. It's just one way of doing it. But it requires you to have > > all plugins being part of one module, in one location. Depending on what > > you want to do, this won't suffice. For example if your app is installed in > > a system path you aren't supposed to write to - how do you install your > > individual plugin? easy_install allows you to install to a folder that is > > contained in the PYTHONPATH, and then you can discover entrypoints. > > > But please, do as we suggested: read the past discussions. > > > Depending on what _you_ actually want to accomplish, you're proposal is > > enough. But don't expect it to become the "one plugin system to rule them > > all"-solution. > > > diez > > Oh, I have read all the links that have been suggested, but I am > looking for the simplest possible solution. > > I have no intention to create the "next Plugin system" I am just > trying to solve my own problem and in the process leave a record of a > fruitfull discussion about plugin systems. > > BTW I have yet to check TRAC's plugin system. I have look at Trac's component based pluging system and I liked it very much. If external dependencies is not an issue I believe this is the best solution. http://trac.edgewall.org/wiki/TracPlugins -- http://mail.python.org/mailman/listinfo/python-list
Re: plugin development best practices
On Feb 22, 2:04 pm, "Paul Boddie" <[EMAIL PROTECTED]> wrote: > On 22 Feb, 16:13, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > > > > Darn. You're right of course - I just got the basic idea, and formed in my > > mind the "get the modules filename, thus the path, glob over it for *py, > > and thus get the subsequent module names"-pattern. Which is trivial of > > course, but not as trivial as just dir(module) > > The __init__.py file of a plugins package could contain something like > this: > > # Start > def init(): > import os > global __all__ > this_dir = os.path.split(__file__)[0] > py_suffix = os.path.extsep + "py" > __all__ = [] > for filename in os.listdir(this_dir): > if os.path.isdir(os.path.join(this_dir, filename)) and \ > os.path.exists(os.path.join(this_dir, filename, "__init__" > + py_suffix)): > __all__.append(filename) > else: > module, suffix = os.path.splitext(filename) > if suffix == py_suffix and module != "__init__": > __all__.append(module) > init() > del init > # End > > This should populate the __all__ attribute of the package with then > names of any submodules or subpackages. Although that in itself won't > provide the names of the plugins via the dir function, the __all__ > attribute is some kind of standard, and things like "from plugins > import *" will import all the known plugins. In fact, if you add such > an import statement to the end of the above code, you'll get all the > names of the plugins stored within the package (and thus returned by > the dir function) because the submodules and subpackages will actually > have been imported. Even reloading the plugins package will update the > __all__ attribute, although things like the unloading or removal of > plugins might be challenging in a solution where such things are > automatically imported. > > Having a variation of the above function in the standard library could > be fairly useful, I suppose. > > Paul Hi Paul, Thanks for the fix. I had not tested my idea. anyway here goes another solution: I create a plugins package containing a single plugin named a.py, with just a single line: print "hi" here is the code for the __init.py: import os plugindir = os.path.split(__file__)[0] for f in os.listdir(plugindir): f = os.path.split(f)[-1] if f.endswith('.py'): f = f.split('.')[0] try: exec('import %s'%f) except: pass Now, if we import the plugins package, we can see module a, in the output of dir: In [1]:import plugins hi In [2]:dir(plugins) Out[2]: ['__builtins__', '__doc__', '__file__', '__init__', '__name__', '__path__', 'a', 'f', 'os', 'plugindir'] best, Flávio -- http://mail.python.org/mailman/listinfo/python-list
ZODB List
Hi, I am a big fan of ZODB and use it stand alone on many project of mine. One of the things I miss is a community around it. I don't care much about ZOPE (though I admire it) and have not being able to find a ZODB focused community. Is there one? thanks -- http://mail.python.org/mailman/listinfo/python-list
distributing a app frozen by cx_freeze
Hi, After a good deal of tunig I managed to freeze my application. I ended up with an executable, and a Bunch of .so files in the install-dir. It runs fine in the original machine. I copied the install folder to another machine but the executable wont run. Here's the traceback: Traceback (most recent call last): File "/home/fccoelho/Downloads/cx_Freeze-3.0.2/initscripts/Console.py", line 26, in ? File "epigrass.py", line 4, in ? ImportError: /home/flavio/freeze/qt.so: undefined symbol: _ZNK9QSGIStyle9classNameEv It is looking for the Original cx_freeze installation!! Do I have to distribute cxFreeze with my app? I don't think so. But in that case, how do I remove this dependency? any help is appreciated Flávio -- http://mail.python.org/mailman/listinfo/python-list
Re: distributing a app frozen by cx_freeze
Thanks for the hint. I'll try to get cx_freeze to bundle up other shared libraries it may not be bundling such as qtcanvas, qtext, qtui, etc. and see if it works. I'll post back the results to help other poor souls like me. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: distributing a app frozen by cx_freeze
Well I managed to get rid of the undefined symbol message by copying all qt libs to the freeze directory, the problem is that now the package is huge (83MB)! So my question is: is there a way to find out exactly which lib is missing ? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: distributing a app frozen by cx_freeze
I know, but the whole point of cx_freeze is to generate standalone executables, so asking for an installation of an specific version of Qt is just a little better than asking the end user to install from source... -- http://mail.python.org/mailman/listinfo/python-list
cx_freeze and matplotlib
I am trying to freeze an application which imports matplotlib. It all works fine on the machine where it was frozen. The executable runs without a glitch. But when I move the directory containing the frozen executable and other libs to a new machine, I get the following error: Traceback (most recent call last): File "/home/fccoelho/Downloads/cx_Freeze-3.0.2/initscripts/Console.py", line 26, in ? File "epigrass.py", line 5, in ? File "Epigrass/manager.py", line 7, in ? File "Epigrass/simobj.py", line 4, in ? File "/usr/lib/python2.4/site-packages/matplotlib/__init__.py", line 457, in ? try: return float(s) File "/usr/lib/python2.4/site-packages/matplotlib/__init__.py", line 245, in wrapper if level not in self.levels: File "/usr/lib/python2.4/site-packages/matplotlib/__init__.py", line 319, in _get_data_path Return the string representing the configuration dir. If s is the RuntimeError: Could not find the matplotlib data files Matplotlib can't find its data files. Apparently this problem comes up in py2exe as well and it is handled like this: from distutils.core import setup import glob import py2exe data = glob.glob(r'C:\Python23\share\matplotlib\*') data.append(r'C:\Python23\share\matplotlib\matplotlibrc') setup( console= ["simple_plot.py"], data_files = [("matplotlibdata", data)], ) This is the only thing I need to solve before I can distribute my frozen package, so please help me here. There must be a way since the frozen works in the original machine but not on the new Which also has the same version of matplotib installed. -- http://mail.python.org/mailman/listinfo/python-list
Re: cx_freeze and matplotlib
My application needs needs matplotlib. So cx_Freeze bundles it in. But it only bundles matplotlib python modules, not its data files! In the original machine I believe that the frozen executable is somehow finding those datafiles in their original locations, which is not desirable, ecause the bundle should be completely independent of external files. -- http://mail.python.org/mailman/listinfo/python-list
what should we use instead of the 'new' module?
How is this code going to look like in Python 3.0? (it's deprecated according to http://docs.python.org/library/new.html#module-new, but it does not tell what to use instead) method = new.instancemethod(raw_func, None, cls) setattr(cls, name, method) Can we write code in python2.5/2.6 that will work in 3.0? -- http://mail.python.org/mailman/listinfo/python-list
whats your favourite object relational mapper?
With so many object relational mappers out there, I wonder which one is the preferred tool among the Pythonists... is there a favourite? Sqlobject, PyDO, SQLAlchemy, dejavu, etc... -- http://mail.python.org/mailman/listinfo/python-list
PyGTK and Window Size
Hi, Currently i am developing a python script that will be executed in Gnome. This script uses the PyGTK library, however i have a question: How can I make my application to remember the last window size when it was closed? This behavior is natural for the majority of Gnome applications (i think). The trivial solution that i've imagined is to save to a config file the current status of the window, but i wish that PyGTK automatic handled this for me. Thanks, Flavio -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie prob: How to write a file with 3 threads?
Is it not possible to acomplish this with a token-based algorithm? With 3 Threads: A, B and C Thread A start with Token. Thread with the token writes the byte and send the token to the next Or python has any issues to a file object shared among a few threads? []'s Flavio On 5/6/07, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: In <[EMAIL PROTECTED]>, est wrote: > I need to write a file using 3 threads simutaniously, e.g. Thread 1 > write the first byte of test.bin with an "a", second thread write the > second byte "b", third thread write the third byte "c". Anyone could > give a little example on how to do that? Simplest solution is: don't do that. Write from one thread and send the date from the other threads via a `Queue.Queue` to the writing thread. Send the number of the thread with the data so the writer thread knows in which order the data has to be written. > I have my code, but it makes python intepreter crash everytime on my > Vista. Show minimal (non-)working code, tell us the exception plus traceback and explain "crash". Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: preferred windows text editor?
I use VIM here too. Mainly because i always switch from Windows to Linux and using the same text editor is a way to avoid getting crazy. []'s Preto On 9 May 2007 15:21:41 -0700, BartlebyScrivener <[EMAIL PROTECTED]> wrote: On May 9, 1:26 pm, "Looney, James B" <[EMAIL PROTECTED]> wrote: > I'm using Vim (http://www.vim.org/). I too vote for VIM. I use it on both Windows XP and Debian Etch. I can't find anything it doesn't do. rd -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Threads and racing conditions
Hi, I have a doubt. Supose that i have the minimun class below: class db: def __init__(self): self.db = {} def read(self, key): return self.db[key] def write(self, key, value): self.db[key] = value and an object of this class is shared among some threads. Is it possible that in a read, the method return a value that is not an old or a new value? In other words, is it possible that a 'read' return (due to a 'write' at the same time by another thread) an invalid value that was never supposed to be there? Thanks, Flavio Preto -- http://mail.python.org/mailman/listinfo/python-list
Python serial data aquisition
Hi, I am using pyserial to acquire data from an A/D converter plugged to my serial port. my hardware represents analog voltages as 12bit numbers. So, according to the manufacturer, this number will be stored in two bytes like this; |-bits(1-8)---| Byte1: x x x n1 n2 n3 n4 n5 Byte2: x n6 n7 n8 n9 n10 n11 n12 where x is some other information, and nx are the digits of my number. My problem is to how to recover my reading from these bytes, since pyserial gives me a character (string) from each byte... I dont know how to throw away the unneeded bits and concatenate the remaining bits to form a number... Flávio Codeço Coelho -- http://mail.python.org/mailman/listinfo/python-list
Re: Python serial data aquisition
[EMAIL PROTECTED] (Michael Fuhr) wrote in message news:<[EMAIL PROTECTED]>... > If the actual byte and/or bit order is different then you'll have > to modify the expression, but this should at least give you ideas. Thanks Michael and Steve, I'll put your Ideas to the test ASAP, meanwhile, could you point me to references to these bit operations in Python? I am new to this stuff, and might need to do more of this to support other hardware... I havent been able to find anything about this on the python documentation.. Thanks a lot!! Flavio -- http://mail.python.org/mailman/listinfo/python-list
Re: Python serial data aquisition
[EMAIL PROTECTED] (Michael Fuhr) wrote in message news:<[EMAIL PROTECTED]>... > If the actual byte and/or bit order is different then you'll have > to modify the expression, but this should at least give you ideas. Hi Michael, It all looks pretty god but there is a couple of things I still don't understand, 1) in Steve's solution (which seems equivalent to your own), he does the masking, shifts by seven, and then sums the two numbers while you, instead of summing, use a logical or. How can these operations be equivalent? or are they? Is the logical or equivalent to a concatenation? 2) why 7? why do we have shift 7 bits? is that so the 8th bit on byte one is aligned with the first bit on the second byte? thanks: -- http://mail.python.org/mailman/listinfo/python-list
Re: Python serial data aquisition
Paul Rubin <http://[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > or something like that. Hi Paul, thanks for your answer. I Noticed, however that although your solution is almost identical to that of Michael (earlier in the thread) your masking for the second byte is different than the one he used. Since hex numbers get me all confused (and python doesn't convert to binary), I was wondering which one is the correct masking... thnaks, Flavio -- http://mail.python.org/mailman/listinfo/python-list
Checking for X availability
I have a program that uses pythondialog for its UI. Pythondialog is a wrapper of the shell dialog and xdialog libs. But I would like for it to switch between using Dialog ( when X is not available ) and xdialog (when X is available) So my question is: how can I check for the availability of X? i.e., How will my program know if its running in a text only console or in console window over X? thanks, Flávio -- http://mail.python.org/mailman/listinfo/python-list
Re: Python serial data aquisition
[EMAIL PROTECTED] (Bengt Richter) wrote in message news:<[EMAIL PROTECTED]>... > On 9 Jan 2005 14:13:28 -0800, [EMAIL PROTECTED] (Flavio codeco coelho) wrote: > > >Hi, > > > >I am using pyserial to acquire data from an A/D converter plugged to > >my serial port. > > > >my hardware represents analog voltages as 12bit numbers. So, according > >to the manufacturer, this number will be stored in two bytes like > >this; > > |-bits(1-8)---| > >Byte1: x x x n1 n2 n3 n4 n5 > >Byte2: x n6 n7 n8 n9 n10 n11 n12 > > > >where x is some other information, and nx are the digits of my number. > > > >My problem is to how to recover my reading from these bytes, since > >pyserial gives me a character (string) from each byte... I dont know > >how to throw away the unneeded bits and concatenate the remaining > >bits to form a number... > > > The others have shown how to recover a 12 bit positive value 0 through 4095, > but if the number is signed, and you want the signed value, you'll have to > find out how signed numbers are represented. An offset is common, in which > case you would subtract 2048 (2**11). If it's two's complement by some chance, > you'll want (I think -- untested ;-) to do num -= 2*(num&2048) instead of > always num -= 2048 > If you need speed in converting large strings of byte pairs, you could > convert pairs of bytes with the array module ('H' for unsigned 2-byte numbers) > and use the resulting 16-bit numbers as indices into another array of final > values > prepared beforehand with redundant information that will accomplish the effect > of masking and shifting and adjusting sign. > If you need this speed, volunteers will magically appear. Maybe even if you > don't ;-) > Regards, > Bengt Richter Hi Bengt, The Idea of using Array is realy cool Though I have to think about it since I would to plot the values as they are sampled... Anyway, how would you set up this array to do the shifting and masking? BTW, since this thread is generating quite a bit of attention let me post a complete description of my problem so that it may serve as reference to others: Hardware: DI-151RS from Dataq (2 analog channels, 2 digital input, single ended/differential recording, max sampling rate 240Hz) connects to the serial pro through a standard db9 plug. Encryption table: B7 B6 B5 B4 B3 B2 B1 B0 Byte1 A4 A3 A2 A1 A0 1 Din 0 Byte2 A11 A10 A9 A8 A7 A6 A5 1 Byte3 B4 B3 B2 B1 B0 1 Din 1 Byte4 B11 B10 B9 B8 B7 B6 B5 1 first two bytes are for analog ch 1 and remaining two are for ch 2. Din stands for digital in. AXX and BXX are the nth bits of each reading. A0 and B0 are the least significant bits. The latest and preferred solution on how to convert these bytes is, according to the suggestion of Chris Liechti (author of pyserial) is: (this is for the first channel only, repeat for the second) import struct l, h = struct.unpack(">BB", ser.read(2)) n = (l >> 3) + ((h >> 1)<<5) struct.unpack returns a tuple of values represented by a string(the output of the read command) packed according to the format specified by ">BB" In this forma string, ">" stands for big Endian representation and "B" stands for unsigned char. If anyone has a better suggestion, speack up! oof! I started this thread knowing next to nothing about this stuff, It seem that I am finally getting the idea! :)) cheers, Flávio -- http://mail.python.org/mailman/listinfo/python-list
Re: Python serial data aquisition
[EMAIL PROTECTED] (Flavio codeco coelho) wrote in message news:<[EMAIL PROTECTED]>... > struct.unpack returns a tuple of values represented by a string(the > output of the read command) packed according to the format specified > by ">BB" > In this forma string, ">" stands for big Endian representation and "B" > stands for unsigned char. > If anyone has a better suggestion, speack up! > oof! I started this thread knowing next to nothing about this stuff, > It seem that I am finally getting the idea! :)) > cheers, > Flávio Ok Folks, Thanks for all the help! Thanks to you and especially to Chris Liechti (pyserial), I managed to finish the Data aquisition module for the Dataq DI-151RS. you can check it out here: http://www.procc.fiocruz.br:8080/procc/Members/flavio/codepy/dataq/ It implements the basic operational functionality, fancier stuff should be added by the user. enjoy! Flávio Codeco Coelho P.S.: I'll be happy to support other hardware from Dataq if people give me access to other devices. -- http://mail.python.org/mailman/listinfo/python-list
circular iteration
hi, is there a faster way to build a circular iterator in python that by doing this: c=['r','g','b','c','m','y','k'] for i in range(30): print c[i%len(c)] thanks, Flávio -- http://mail.python.org/mailman/listinfo/python-list