Re: [Tutor] 'module' object has no attribute (setting a class attribute)

2010-10-15 Thread Steven D'Aprano
On Sat, 16 Oct 2010 08:20:37 am Tim Johnson wrote: > I have two questions regarding this: > 1)Am I using the correct method to set a class attribute? Yes. The way to set a class attribute is the same way that you set an attribute on *any* object: some_object.attribute_name = something In your

Re: [Tutor] Moving my C++ code to Python?

2010-10-15 Thread Chris Fuller
SWIG supports opaque pointers that you can pass into and out of Python without any problems. Working with SWIG isn't that bad for basic stuff, although it can get complicated if you need to have it interpret exotica like references, structures, or such for Python. Having a good C++ background

Re: [Tutor] Moving my C++ code to Python?

2010-10-15 Thread Alan Gauld
"Paul" wrote I would like to make modules for python. The problem is that the vector of structs that is very large. First, is it possible to pass such structures around to and from python and C/C++? Yes, Try looking at SWIG for one approach to making C/C++ code accesible to Python which ma

Re: [Tutor] Moving my C++ code to Python?

2010-10-15 Thread Paul
On Fri, Oct 15, 2010 at 3:07 PM, David Hutto wrote: > This isn't an answer to your question, but I'm doing about the same in > reverse(it sounds like) as you're doing. More directly just processing > data for 2-d/3d graphs using matplotlib and wxpython. So, I was I'm afraid it is a different prob

Re: [Tutor] Moving my C++ code to Python?

2010-10-15 Thread David Hutto
This isn't an answer to your question, but I'm doing about the same in reverse(it sounds like) as you're doing. More directly just processing data for 2-d/3d graphs using matplotlib and wxpython. So, I was wondering if you think it's similar to those ends, and good enough to let someone else look a

[Tutor] Moving my C++ code to Python?

2010-10-15 Thread Paul
Hi there, I've been using C/C++ for many years (python, just reading about it). I have a software written in C/C++ but considering porting most of it to python, as it seems like it's a better choice for decision making portion of the code. I'm also thinking about having a 'matlab' like interface

[Tutor] 'module' object has no attribute (setting a class attribute)

2010-10-15 Thread Tim Johnson
My intention is to set a class attribute so that any number of instantiations will have this value. the module is tmpl.py. the class is tmpl. if from the script I do this: import tmpl tmpl.tmpl.templatepath = kbLib.templatepath I get error message: 'module' object has no attribute 'templatepath

Re: [Tutor] Converting from unicode to nonstring

2010-10-15 Thread Ahmed AL-Masri
hi I faced this problem before and people of tutor helped me to solve it by only one line ex. a=input_raw("your non string")## I input 1,2,3,4 5 6 7 or u[1,2,3,4] a.replace(",", " ","[","]","u").split() ## you can put any kind of unicode that you expect inside the " " a=map(float, a) print a

Re: [Tutor] Converting from unicode to nonstring

2010-10-15 Thread Steven D'Aprano
On Fri, 15 Oct 2010 09:26:48 pm David Hutto wrote: > Ok, Let me restate and hopefully further clarify. > > 1. I have a field for a wxpython app using matplotlib to display > 2. I have a sqlite3 db which I'm retrieving information from Both of those points are irrelevant. > 3. The sqlitle data is

Re: [Tutor] Converting from unicode to nonstring

2010-10-15 Thread Dave Angel
On 2:59 PM, David Hutto wrote: Ok, Let me restate and hopefully further clarify. 1. I have a field for a wxpython app using matplotlib to display 2. I have a sqlite3 db which I'm retrieving information from 3. The sqlitle data is returned as unicode: u'field' 4. The portion of the matplotlib

Re: [Tutor] Converting from unicode to nonstring

2010-10-15 Thread Peter Otten
David Hutto wrote: > Hey Buddy Pals, ? > I receive the following output from a sqlite db > > (u'graph1', u'Line', u'222', u'BLUE', u'1,2,3,4', u'True', u'0,5,0,10') How did the string u"1,2,3,4" get into the database in the first place? The sqlite3 module offers a mechanism to convert data fro

Re: [Tutor] Converting from unicode to nonstring

2010-10-15 Thread Joel Goldstick
On Fri, Oct 15, 2010 at 6:26 AM, David Hutto wrote: > Ok, Let me restate and hopefully further clarify. > > 1. I have a field for a wxpython app using matplotlib to display > > 2. I have a sqlite3 db which I'm retrieving information from > > 3. The sqlitle data is returned as unicode: u'field' >

Re: [Tutor] Converting from unicode to nonstring

2010-10-15 Thread David Hutto
On Thu, Oct 14, 2010 at 10:09 PM, Steven D'Aprano wrote: > On Fri, 15 Oct 2010 04:43:46 am David Hutto wrote: > >> Fixed with: >> >> self.lines = self.newplot.plot(eval(self.plot)) > > Anytime you use eval, chances are that it isn't fixed at all, but just > badly and dangerously papered over. > >

Re: [Tutor] Converting from unicode to nonstring

2010-10-15 Thread David Hutto
On Thu, Oct 14, 2010 at 7:00 PM, Alan Gauld wrote: > > "David Hutto" wrote > >> it's not necessary to worry about insertion of data other than my own >> inputs. > > But can you be sure that you won't accidentally mistype something > that eval can read as valid code but that does something unexpec

Re: [Tutor] Converting from unicode to nonstring

2010-10-15 Thread David Hutto
On Thu, Oct 14, 2010 at 6:56 PM, Alan Gauld wrote: > > "David Hutto" wrote > >> In other words I needed (1,2,3,4) not u'(1,2,3,4)' to be inserted >> for variable self.plot > > You appear to be making this much more difficult than it needs to be. > The values you retrieve from the database are str

Re: [Tutor] Converting from unicode to nonstring

2010-10-15 Thread David Hutto
> In which case the code Sanders sent you is a much more sensible way of > recovering your data. Evalling the string u'plot' still doesn't make much > sense to me though. But it's the only thing working correctly though, so until I have a better solution, I'm forced to deal with any bugs in interp

Re: [Tutor] Converting from unicode to nonstring

2010-10-15 Thread David Hutto
On Thu, Oct 14, 2010 at 2:58 PM, Adam Bark wrote: > On 14/10/10 19:29, David Hutto wrote: >> >> On Thu, Oct 14, 2010 at 2:19 PM, Sander Sweers >>  wrote: >> >>> >>> On 14 October 2010 16:14, David Hutto  wrote: >>> (u'graph1', u'Line', u'222', u'BLUE', u'1,2,3,4', u'True', u'0,5,0,10') >

Re: [Tutor] Converting from unicode to nonstring

2010-10-15 Thread David Hutto
On Thu, Oct 14, 2010 at 3:02 PM, Sander Sweers wrote: > On 14 October 2010 20:29, David Hutto wrote: >> Actually, I needed it to be converted to something without a string >> attached to it. See a post above, and it was fixed by eval(), > > Using eval is a big security risk and is generally not r

Re: [Tutor] Converting from unicode to nonstring

2010-10-15 Thread David Hutto
Ok, Let me restate and hopefully further clarify. 1. I have a field for a wxpython app using matplotlib to display 2. I have a sqlite3 db which I'm retrieving information from 3. The sqlitle data is returned as unicode: u'field' 4. The portion of the matplotlib code is filled in, in a for x in

Re: [Tutor] Statistic-Program Problems! Please Help Quickly!

2010-10-15 Thread Vince Spicer
On Thu, Oct 14, 2010 at 10:11 PM, Colleen Glaeser wrote: > BTW, the error message my program gives me for the B and M functions is: > > Traceback (most recent call last): > File "I:\Lab 7 wierd stat data.py", line 49, in > B() > File "I:\Lab 7 wierd stat data.py", line 44, in B > > ((

Re: [Tutor] join question

2010-10-15 Thread Roelof Wobben
Hello, Solved it. Problem was that I used fileinfo instead of getinfo. Thanks for the help. Roelof Date: Thu, 14 Oct 2010 18:55:50 -0400 > From: joel.goldst...@gmail.com > To: tutor@python.org > Subject: Re: [Tutor] join question > > > > On Thu, Oct 14, 2010 at 6:43 PM, Alan Gaul

Re: [Tutor] Statistic-Program Problems! Please Help Quickly!

2010-10-15 Thread Steven D'Aprano
On Fri, 15 Oct 2010 03:09:57 pm Colleen Glaeser wrote: > Now, my functions for X, Y, P, and Q are correct, but I have a couple > of problems when it comes to continuing. First of all, despite what > my teacher has told me, my method for trying to multiply X,Y,P, and > Q's results in the functions

Re: [Tutor] Networking

2010-10-15 Thread James Mills
On Fri, Oct 15, 2010 at 3:06 PM, Evert Rol wrote: > The very last example on http://docs.python.org/library/socketserver.html may > help you. > Or perhaps the asyncore/asynchat modules. Alternatively Twisted (1) or circuits (2) cheers James 1. http://twistedmatrix.com/trac/ 2. http://bitbucket