Re: i don't understand this python class

2020-06-29 Thread DL Neil via Python-list
On 30/06/20 5:14 AM, joseph pareti wrote: I have piece of code with constructs as follows: *class* *SentimentNetwork**:* *def* __init__*(*self*,* reviews*,* labels*,* hidden_nodes *=* 10*,* learning_rate *=* 0.1*):* np*.*random*.*seed*(*1*)* self*.*init_network*(**len**(*s

Re: i don't understand this python class

2020-06-29 Thread Calvin Spealman
You are misreading the original example. `init_network` is defined as a method on the class, and called in its initializer. There is no property named "init_network". On Mon, Jun 29, 2020 at 1:18 PM joseph pareti wrote: > I have piece of code with constructs as follows: > > *class* *SentimentNet

i don't understand this python class

2020-06-29 Thread joseph pareti
I have piece of code with constructs as follows: *class* *SentimentNetwork**:* *def* __init__*(*self*,* reviews*,* labels*,* hidden_nodes *=* 10*,* learning_rate *=* 0.1*):* np*.*random*.*seed*(*1*)* self*.*init_network*(**len**(*self*.*review_vocab*),*hidden_nodes*,* 1*,

Re: How to instantiate a custom Python class inside a C extension?

2020-04-01 Thread MRAB
On 2020-04-01 13:42, Musbur wrote: Hi guys, I'm wondering how to create an instance of an extension class I wrote. There's a minimal self-contained C module at the bottom of this post which exports two things: 1) a class Series, and 2) a function make_series() which is supposed to create a Serie

Re: How to instantiate a custom Python class inside a C extension?

2020-04-01 Thread Rhodri James
On 01/04/2020 18:24, Musbur wrote: Am 01.04.2020 15:01 schrieb Rhodri James: I believe you do it in C as you would in Python: you call the Series class! pyseries = PyObject_CallObject((PyObject *)&series_type, NULL); Well, that dumps core just as everything else I tried. What does work, ho

Re: How to instantiate a custom Python class inside a C extension?

2020-04-01 Thread Musbur
Am 01.04.2020 15:01 schrieb Rhodri James: I believe you do it in C as you would in Python: you call the Series class! pyseries = PyObject_CallObject((PyObject *)&series_type, NULL); Well, that dumps core just as everything else I tried. What does work, however, is calling PyType_Ready first

Re: How to instantiate a custom Python class inside a C extension?

2020-04-01 Thread Rhodri James
On 01/04/2020 13:42, Musbur wrote: So when created from C, neither the "new" nor the "init" functions are called on the object, only "finalize". No wonder I get segfaults in the real life application. So how is this done right? Here's the C module: I believe you do it in C as you would in Py

How to instantiate a custom Python class inside a C extension?

2020-04-01 Thread Musbur
Hi guys, I'm wondering how to create an instance of an extension class I wrote. There's a minimal self-contained C module at the bottom of this post which exports two things: 1) a class Series, and 2) a function make_series() which is supposed to create a Series object on the C side and retur

NEED ASSISTANCE WITH PYTHON CLASS

2020-03-28 Thread gentleman . for . ever . and . ever
Hi, I need help with coding assignments (python to be exact) in school. I am willing to pay for your attention by the hour. Please email me at aifa...@protonmail.com if you’re interested. Please only reach out if you’re not a beginner. Trying to avoid the blind being led by the blind. Thanks! --

Re: How to call a Python Class?

2016-05-03 Thread Ben Finney
David Shi via Python-list writes: > I found a Python class within an Open Source software. > I would like to use it in my own Python script. > I tried to import it, but I got following message. Your text is mangled in transit. Please post only plain text messages (avoid HTML or ot

Re: How to call a Python Class?

2016-05-03 Thread Chris Angelico
On Wed, May 4, 2016 at 8:56 AM, David Shi via Python-list wrote: > I found a Python class within an Open Source software. > I would like to use it in my own Python script. > I tried to import it, but I got following message. > from intersection import *Traceback (most recent call

How to call a Python Class?

2016-05-03 Thread David Shi via Python-list
I found a Python class within an Open Source software. I would like to use it in my own Python script. I tried to import it, but I got following message. from intersection import *Traceback (most recent call last):  File "", line 1, in     from intersection import *ImportError: bad ma

Re: How to create an instance of a python class from C++

2014-03-12 Thread Stefan Behnel
Barry Scott, 11.03.2014 22:37: > On 5 Mar 2014, at 00:14, Bill wrote: >> I can't figure out how to create an instance >> of a python class from 'C++': > > Why not use pycxx from http://sourceforge.net/projects/cxx/? > > This lib does all the heavy li

Re: How to create an instance of a python class from C++

2014-03-11 Thread Barry Scott
On 5 Mar 2014, at 00:14, Bill wrote: > Hello: > > I can't figure out how to create an instance > of a python class from 'C++': > Why not use pycxx from http://sourceforge.net/projects/cxx/? This lib does all the heavy lifting for you for both python2 and

Re: How to create an instance of a python class from C++

2014-03-05 Thread Gene Heskett
On Wednesday 05 March 2014 17:09:53 Grant Edwards did opine: > On 2014-03-05, Alister wrote: > >>> Why are you creating an ABC? > >> > >> Because it was the first binary computer that did calculations with > >> electronic switching elements (gates), and it would be really cool to > >> have one!

Re: How to create an instance of a python class from C++

2014-03-05 Thread Grant Edwards
On 2014-03-05, Alister wrote: >> >>> Why are you creating an ABC? >> >> Because it was the first binary computer that did calculations with >> electronic switching elements (gates), and it would be really cool to >> have one! The ABC also pioneered the use of capciators as regenerative >> storage

Re: How to create an instance of a python class from C++

2014-03-05 Thread Alister
On Wed, 05 Mar 2014 16:08:00 +, Grant Edwards wrote: > On 2014-03-05, Ian Kelly wrote: >> On Tue, Mar 4, 2014 at 5:14 PM, Bill wrote: >>> Hello: >>> >>> I can't figure out how to create an instance of a python class from >>> 'C++'

Re: How to create an instance of a python class from C++

2014-03-05 Thread Grant Edwards
On 2014-03-05, Ian Kelly wrote: > On Tue, Mar 4, 2014 at 5:14 PM, Bill wrote: >> Hello: >> >> I can't figure out how to create an instance >> of a python class from 'C++': >> >> ( I am relatively new to Python so excuse some of the fol

Re: How to create an instance of a python class from C++

2014-03-05 Thread Bill
> > So far, so good. The object that was passed in was the "Derived" > class object. Since you presumably only want class objects to be > passed in, you might want to check that here using PyType_Check. > Yes. Will do. > > > PyTypeObject *typ = class_decl->ob_type; > > In Python, y

Re: How to create an instance of a python class from C++

2014-03-04 Thread Ian Kelly
On Tue, Mar 4, 2014 at 5:14 PM, Bill wrote: > Hello: > > I can't figure out how to create an instance > of a python class from 'C++': > > ( I am relatively new to Python so excuse some of > the following. ) > > In a .py file I create an ABC and then s

How to create an instance of a python class from C++

2014-03-04 Thread Bill
Hello: I can't figure out how to create an instance of a python class from 'C++': ( I am relatively new to Python so excuse some of the following. ) In a .py file I create an ABC and then specialize it: from MyMod import * from abc import ABCMeta, abstractmethod

Re: Python class and variable issue(newby question!)

2013-03-29 Thread Dave Angel
On 03/29/2013 06:17 PM, Sam Berry wrote: Thanks for the responses! My issue was sorted with Benjamins post, just printing s worked. Cheers for the info though Chris, if i have any further issues il post them with some working code. In that case, you probably should add a line like: s = Non

Re: Python class and variable issue(newby question!)

2013-03-29 Thread Chris Angelico
On Sat, Mar 30, 2013 at 9:51 AM, Steven D'Aprano wrote: > On Sat, 30 Mar 2013 08:24:00 +1100, Chris Angelico wrote: > >> On Sat, Mar 30, 2013 at 8:12 AM, Sam Berry >> wrote: >>> class test() >>> s = 1 >>> >>> def test1() >>> global s >>> s = 2 > >> That's not a global, tha

Re: Python class and variable issue(newby question!)

2013-03-29 Thread Steven D'Aprano
On Sat, 30 Mar 2013 08:24:00 +1100, Chris Angelico wrote: > On Sat, Mar 30, 2013 at 8:12 AM, Sam Berry > wrote: >> class test() >> s = 1 >> >> def test1() >> global s >> s = 2 > That's not a global, that's a class variable. /me thwacks Chris with a halibut. Not only i

Re: Python class and variable issue(newby question!)

2013-03-29 Thread Chris Angelico
On Sat, Mar 30, 2013 at 9:17 AM, Sam Berry wrote: > Thanks for the responses! My issue was sorted with Benjamins post, just > printing s worked. > > Cheers for the info though Chris, if i have any further issues il post them > with some working code. Awesome! Always happy to help out. ChrisA -

Re: Python class and variable issue(newby question!)

2013-03-29 Thread Sam Berry
Thanks for the responses! My issue was sorted with Benjamins post, just printing s worked. Cheers for the info though Chris, if i have any further issues il post them with some working code. Sam -- http://mail.python.org/mailman/listinfo/python-list

Re: Python class and variable issue(newby question!)

2013-03-29 Thread Benjamin Kaplan
On Fri, Mar 29, 2013 at 2:12 PM, Sam Berry wrote: > Hey, > > Im new to object orientated programming and have an issue with using classes. > Im using the kivy module, a GUI creator , so posting the actual code may > confuse. But an example of what im trying to achieve is below > > class test() >

Re: Python class and variable issue(newby question!)

2013-03-29 Thread Chris Angelico
On Sat, Mar 30, 2013 at 8:12 AM, Sam Berry wrote: > class test() > s = 1 > > def test1() > global s > s = 2 > > def test2() > global s > s = 3 > > def test3() > global s > s = 4 That's not a global, that's a class variable. But to gi

Python class and variable issue(newby question!)

2013-03-29 Thread Sam Berry
Hey, Im new to object orientated programming and have an issue with using classes. Im using the kivy module, a GUI creator , so posting the actual code may confuse. But an example of what im trying to achieve is below class test() s = 1 def test1() global s s = 2

Re: Python Class

2013-02-01 Thread Rodrick Brown
On Friday, February 1, 2013, Charles Hoskinson wrote: > I'm developing an online course for beginning python programmers starting > from basic syntax through object oriented design and GUI. I'd like to > include some helpful community resources like Code Academy in the appendix > and I was wonderi

Re: Python Class

2013-02-01 Thread Steven D'Aprano
Charles Hoskinson wrote: > I'm developing an online course for beginning python programmers starting > from basic syntax through object oriented design and GUI. I'd like to > include some helpful community resources like Code Academy in the appendix > and I was wondering if this community has some

Re: Fool Python class with imaginary members (serious guru stuff inside)

2012-09-20 Thread Steven D'Aprano
On Thu, 20 Sep 2012 06:52:07 -0700, Jure Erznožnik wrote: > I'm trying to create a class that would lie to the user that a member is > in some cases a simple variable and in other cases a class. The nature > of the member would depend on call syntax like so: > 1. x = obj.member #x becomes the "si

Re: Fool Python class with imaginary members (serious guru stuff inside)

2012-09-20 Thread Terry Reedy
On 9/20/2012 9:52 AM, Jure Erznožnik wrote: I'm trying to create a class that would lie to the user that a member is in some cases a simple variable and in other cases a class. The nature of the member would depend on call syntax like so: 1. x = obj.member #x becomes the "simple" value containe

Fool Python class with imaginary members (serious guru stuff inside)

2012-09-20 Thread Jure Erznožnik
I'm trying to create a class that would lie to the user that a member is in some cases a simple variable and in other cases a class. The nature of the member would depend on call syntax like so: 1. x = obj.member #x becomes the "simple" value contained in member 2. x = obj.member.another_member #

Re: A Python class

2012-09-06 Thread Chris Angelico
course python' for taught courses. > At least 2 of MIT's self-guided OpenCourseWare courses use Python. Note this subtle distinction. A Python course will (theoretically, at least!) teach you how to write Python code. A Python class is a collection of methods and stuff. A trivial

Re: A Python class

2012-09-06 Thread Terry Reedy
On 9/6/2012 11:08 AM, Yves S. Garret wrote: I'd like to know if there are any online Python classes offered online from reliable institutions that you would recommend. Google 'online programming course python' for taught courses. At least 2 of MIT's self-guided OpenCourseWare courses use P

Re: Instantiate a python class object in C

2012-03-14 Thread Dids
Ok, I have it :) PyImport_Import , PyModule_GetDict, PyDict_GetItemString and PyObject_CallObject Need to take a second look at cython when I have a spare cycle or 2. Thanks for the the tip :) A+ Dids, -- http://mail.python.org/mailman/listinfo/python-list

Re: Instantiate a python class object in C

2012-03-14 Thread Stefan Behnel
unction, I take an instance of the "demo" class and do > my magic. It's working, all is good. > > What I can't figure out is how to create a second C function that > returns a new instance to the "demo" class to python. > There must a be tutorial so

Instantiate a python class object in C

2012-03-14 Thread Dids
It's working, all is good. What I can't figure out is how to create a second C function that returns a new instance to the "demo" class to python. There must a be tutorial somewhere, but I can't find anything. I do not want to define a new python class in C. Another e

Re: How to get python class serializable and well parsed by JSON

2011-03-11 Thread Gennadiy Zlobin
I can not open your link. Are you sure you provided the correct link? - Gennadiy On Fri, Mar 11, 2011 at 10:36 PM, Arthur Mc Coy <1984docmc...@gmail.com>wrote: > Currently trying to pick up my ava > http://en.gravatar.com/christinasanders21 > for StackOverflow, which site I found very good fo

Re: How to get python class serializable and well parsed by JSON

2011-03-11 Thread Sophie Sperner
Ok, guys. I used my bro account. Now I'm here. By the way is anybody going to be in Paris Sunday night ? I invite you if you would help :))) Kiss, well yet 30 minutes at work and I'm free... Sophie -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get python class serializable and well parsed by JSON

2011-03-11 Thread Arthur Mc Coy
Currently trying to pick up my ava http://en.gravatar.com/christinasanders21 for StackOverflow, which site I found very good for my questions, didn't I? Yes, and there are problem when adding a picture. Web admins should be careful. Can anyone explain me my problem ? : Christina -- http:/

Re: How to get python class serializable and well parsed by JSON

2011-03-11 Thread Arthur Mc Coy
Common guys, help me, sweet heart to finish my job and go with my friend in the bar. Today we have a blues night :) Love it! Christina -- http://mail.python.org/mailman/listinfo/python-list

How to get python class serializable and well parsed by JSON

2011-03-11 Thread Arthur Mc Coy
Hi people, I've created very nice post here: http://stackoverflow.com/questions/5274690/how-to-get-python-class-serializable-and-well-parsed-by-json-custom-encoder-deco Yes, there are solutions over the internet, but nothing works for my custom types. If you could answer, please read it

May "Introduction to Python" class

2010-04-27 Thread Steve Holden
Holden Web is pleased to announce the next run of its popular three-day "Introduction to Python" class in Washington DC on May 11-13, 2010. Further details of all current event listings are available from http://holdenweb.eventbrite.com/ regards Steve -- Steve Holden

JSR223 Access Python class instances through Java

2009-11-12 Thread Jared Klumpp
I am trying to access (from Java) a python class that extends a Java interface. The following program runs fine in the jython console (I can instantiate Tada, call t.getName() and everything prints correctly.) However, if I invoke test1() from Java using JSR223, the returned object is inaccessible

Re: Storing a C pointer in a Python class instance

2009-10-06 Thread lallous
his CObject? Maybe we can help you choose a better way to handle it at the C level. I am wrapping a C++ pointer with the python object. That way I can tell with which C++ object a given python class instance is associated. The thing is when developing, I need to pickle but I don't nee

Re: Storing a C pointer in a Python class instance

2009-09-30 Thread sturlamolden
cator is as reliable as a custom > type's tp_dealloc. You are right. I did not look at the PyCObject_* API close enough. I thought of wrapping the CObject with a Python class, and calling the destructor from __del__. That would be less reliable. S.M. -- http://mail.python.org/mailman/listinfo/python-list

Re: Storing a C pointer in a Python class instance

2009-09-30 Thread Carl Banks
On Sep 29, 11:16 am, sturlamolden wrote: > On 29 Sep, 19:11, Carl Banks wrote: > > > CObjects can be passed a C function as a deallocator; this should work > > as reliably as a custom class deallocator. > > Except that __del__ prevents cyclic GC. You are mistaken on two counts. First of all, a

Re: Storing a C pointer in a Python class instance

2009-09-30 Thread Carl Banks
On Sep 30, 5:24 am, "lallous" wrote: > Hello > > After using the PyCObject, I cannot pickle the class anymore. > Any simple solution to this problem? (or resorting to __reduce__ is the only > solution?) You can't pickle a CObject, you'd have to create a custom type (one that implements one of th

Re: Storing a C pointer in a Python class instance

2009-09-30 Thread lallous
Hello After using the PyCObject, I cannot pickle the class anymore. Any simple solution to this problem? (or resorting to __reduce__ is the only solution?) Thanks, Elias "Falcolas" wrote in message news:9d3790aa-f7d9-4bb5-a81f-5428b2d60...@v25g2000yqk.googlegroups.com... On Sep 29, 2:27 am

Re: Storing a C pointer in a Python class instance

2009-09-30 Thread lallous
Thanks everyone. Finally, I used Falcolas suggestion and took into consideration sturlamolden's comments. Regards, Elias "lallous" wrote in message news:h9sgcn$iv...@aioe.org... Hello From my C extension module I want to store a C pointer in a given PyObject. The only way I figure how to

Re: Storing a C pointer in a Python class instance

2009-09-29 Thread sturlamolden
On 29 Sep, 19:11, Carl Banks wrote: > CObjects can be passed a C function as a deallocator; this should work > as reliably as a custom class deallocator. > > Carl Banks Except that __del__ prevents cyclic GC. -- http://mail.python.org/mailman/listinfo/python-list

Re: Storing a C pointer in a Python class instance

2009-09-29 Thread Carl Banks
On Sep 29, 9:42 am, sturlamolden wrote: > You can use PyCObject, or write your own extension type that wraps the > pointer (very easy to to with Cython or Pyrex). The advantage of using > an extension type is you have a guarantee from Python on the > deallocator method being called (cdef __dealloc

Re: Storing a C pointer in a Python class instance

2009-09-29 Thread sturlamolden
cdef __dealloc__ in Cython). If the pointer references a resource that needs to be closed, this is safer than using a __del__ method in a Python class. -- http://mail.python.org/mailman/listinfo/python-list

Re: Storing a C pointer in a Python class instance

2009-09-29 Thread Falcolas
On Sep 29, 2:27 am, "lallous" wrote: > Hello > > From my C extension module I want to store a C pointer in a given PyObject. > > The only way I figure how to do it is to use Py_BuildValues and store the > poiner casted to Py_ssize_t, thus: > > Py_BuildValues("n", (Py_ssize_t)my_ptr) > > Can it be

Storing a C pointer in a Python class instance

2009-09-29 Thread lallous
Hello From my C extension module I want to store a C pointer in a given PyObject. The only way I figure how to do it is to use Py_BuildValues and store the poiner casted to Py_ssize_t, thus: Py_BuildValues("n", (Py_ssize_t)my_ptr) Can it be done differently? Regards, Elias -- http://ma

Visualization of Python Class Hierarchy

2009-07-16 Thread lh
I would like to automatically generate this for my program. I am running python in an eclipse context (pydev). I am not familiar with the best current tools. Thank you -- http://mail.python.org/mailman/listinfo/python-list

Intro to Python class, 7/21-23, Ft Worth TX

2009-07-02 Thread Rich Drehoff
We are looking for someone that can help with the subject class, Intro to Python class, 7/21-23, Ft Worth TX. Please let me know if you can help. Would need your resume and best possible daily rate. Best regards, Rich Drehoff TechnoTraining, Inc. 328 Office Square Lane, Ste. 202

Re: Python class gotcha with scope?

2009-06-20 Thread billy
great, thanks for the quick responses :) On Jun 21, 2:41 am, Carl Banks wrote: > On Jun 20, 11:32 pm, billy wrote: > > > I don't quite understand why this happens. Why doesn't b have its own > > version of r? If r was just an int instead of a dict, then it would. > > > >>> class foo: > > > ...

Re: Python class gotcha with scope?

2009-06-20 Thread Carl Banks
On Jun 20, 11:32 pm, billy wrote: > I don't quite understand why this happens. Why doesn't b have its own > version of r? If r was just an int instead of a dict, then it would. > > >>> class foo: > > ...     r = {} > ...     def setn(self, n): > ...             self.r["f"] = n > ...>>> a = foo() >

Re: Python class gotcha with scope?

2009-06-20 Thread Vincent
On Jun 21, 2:38 pm, Vincent wrote: > On Jun 21, 2:32 pm, billy wrote: > > > > > I don't quite understand why this happens. Why doesn't b have its own > > version of r? If r was just an int instead of a dict, then it would. > > > >>> class foo: > > > ...     r = {} > > ...     def setn(self, n): >

Re: Python class gotcha with scope?

2009-06-20 Thread Vincent
On Jun 21, 2:32 pm, billy wrote: > I don't quite understand why this happens. Why doesn't b have its own > version of r? If r was just an int instead of a dict, then it would. > > >>> class foo: > > ...     r = {} > ...     def setn(self, n): > ...             self.r["f"] = n > ...>>> a = foo() >

Python class gotcha with scope?

2009-06-20 Thread billy
I don't quite understand why this happens. Why doesn't b have its own version of r? If r was just an int instead of a dict, then it would. >>> class foo: ... r = {} ... def setn(self, n): ... self.r["f"] = n ... >>> a = foo() >>> a.setn(4) >>> >>> b = foo() >>> b.r {'f': 4} th

Re: Final Python Class of 2009

2008-11-11 Thread Steve Holden
[EMAIL PROTECTED] wrote: > >> Steve, have you been in Guido's time machine again? > > Steve> No, honest (hides hands behind back). > > Well then what's that red stuff on your face that looks like strawberry jam? > Could it be the special grease we store next to the keys to the time > mach

Re: Final Python Class of 2009

2008-11-11 Thread skip
>> Steve, have you been in Guido's time machine again? Steve> No, honest (hides hands behind back). Well then what's that red stuff on your face that looks like strawberry jam? Could it be the special grease we store next to the keys to the time machine? Skip -- http://mail.python.org/m

Re: Final Python Class of 2009

2008-11-11 Thread Steve Holden
Steven D'Aprano wrote: > On Mon, 10 Nov 2008 22:14:16 -0500, Steve Holden wrote: > > Subject: Final Python Class of 2009 > > Steve, have you been in Guido's time machine again? > :-) > > No, honest (hides hands behind back). regards Steve -- Steve Holden

Re: Final Python Class of 2008

2008-11-11 Thread Steve Holden
Steve Holden wrote: > As the year draws to a close, Holden Web is pleased to remind readers > that its final public "Introduction to Python" class of this year will > be held from 9-11 December at our education center close to Washington, DC. > > There are several ho

Re: Final Python Class of 2009

2008-11-10 Thread Steven D'Aprano
On Mon, 10 Nov 2008 22:14:16 -0500, Steve Holden wrote: Subject: Final Python Class of 2009 Steve, have you been in Guido's time machine again? -- Steven (not Steve Holden, another one) -- http://mail.python.org/mailman/listinfo/python-list

Final Python Class of 2009

2008-11-10 Thread Steve Holden
As the year draws to a close, Holden Web is pleased to remind readers that its final public "Introduction to Python" class of this year will be held from 9-11 December at our education center close to Washington, DC. There are several hotels conveniently located within walking distan

2009 Python class schedule

2008-11-06 Thread Mark Lutz
A page describing our 2009 Python class offerings has just been posted here: http://home.earthlink.net/~python-training/2009-public-classes.htm The first class in 2009 will be held January 27-30 in Colorado, and is now open for enrollments. These are public classes, open to individuals. They

Re: Simple Python class questions

2008-06-20 Thread David C. Ullrich
In article <[EMAIL PROTECTED]>, Lie <[EMAIL PROTECTED]> wrote: > On Jun 19, 7:21 pm, Ulrich Eckhardt <[EMAIL PROTECTED]> wrote: > > John Dann wrote: > > > Let's say I define the class in a module called comms.py. The class > > > isn't really going to inherit from any other class (except presumab

Re: Simple Python class questions

2008-06-20 Thread Lie
On Jun 19, 10:49 pm, Ulrich Eckhardt <[EMAIL PROTECTED]> wrote: > Lie wrote: > > I think it's not that hard to see that it's just a pseudo code > > "...in comms.py I have: ..." actually explicitly says that it is actual code > from a file. > > *shrug* > > Uli > I'm not sure how you think saying 'i

Re: Simple Python class questions

2008-06-20 Thread Duncan Booth
John Dann <[EMAIL PROTECTED]> wrote: > Yes I was wondering about that, but I wasn't clear about when 'body' > code (ie not contained within a def block) in the module might run > under Python. So it seemed to be safer to place the import statement > inside the 'constructor' to get the earliest war

Re: Simple Python class questions

2008-06-20 Thread cokofreedom
> > Yes I was wondering about that, but I wasn't clear about when 'body' > code (ie not contained within a def block) in the module might run > under Python. So it seemed to be safer to place the import statement > inside the 'constructor' to get the earliest warning of non-visibility > of pyserial

Re: Simple Python class questions

2008-06-20 Thread John Dann
Many thanks for the further comments: On Thu, 19 Jun 2008 21:24:31 -0400, Terry Reedy <[EMAIL PROTECTED]> wrote: >> def __init__(self): >> Try >> Import serial # the pyserial library >The import should be at module level. You only want to do it once, not

Re: Simple Python class questions

2008-06-19 Thread Terry Reedy
John Dann wrote: Let's say I define the class in a module called comms.py. The class isn't really going to inherit from any other class (except presumably in the most primitive base-class sense, which is presumably automatic and implicit in using the class keyword). Let's call the class serial

Re: Simple Python class questions

2008-06-19 Thread Ulrich Eckhardt
Lie wrote: > I think it's not that hard to see that it's just a pseudo code "...in comms.py I have: ..." actually explicitly says that it is actual code from a file. *shrug* Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 -- http://mail.python.org/ma

Re: Simple Python class questions

2008-06-19 Thread Lie
On Jun 19, 7:21 pm, Ulrich Eckhardt <[EMAIL PROTECTED]> wrote: > John Dann wrote: > > Let's say I define the class in a module called comms.py. The class > > isn't really going to inherit from any other class (except presumably > > in the most primitive base-class sense, which is presumably automat

Re: Simple Python class questions

2008-06-19 Thread Cédric Lucantis
27;object' - ie (object) - you're not just using 'object' as a > placeholder where there should be a more specific class name or > object? Right. 'object' is a builtin python class, used as a base for all classes as in many OO languages. -- Cédric Lucantis -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple Python class questions

2008-06-19 Thread John Dann
Many thanks for the speedy replies. On Thu, 19 Jun 2008 14:14:02 +0200, Cédric Lucantis <[EMAIL PROTECTED]> wrote: >Le Thursday 19 June 2008 13:54:03 John Dann, vous avez écrit : >> Let's say I define the class in a module called comms.py. The class >> isn't really going to inherit from any other

Re: Simple Python class questions

2008-06-19 Thread Ulrich Eckhardt
John Dann wrote: > Let's say I define the class in a module called comms.py. The class > isn't really going to inherit from any other class (except presumably > in the most primitive base-class sense, which is presumably automatic > and implicit in using the class keyword). Let's call the class > s

Re: Simple Python class questions

2008-06-19 Thread Lie
On Jun 19, 6:54 pm, John Dann <[EMAIL PROTECTED]> wrote: > A Python newbie, but some basic understanding of how classes, objects > etc work in eg VB.Net. However, I'm struggling a little to translate > this knowledge into the Python context. > > I'm trying to teach myself this aspect of Python by w

Re: Simple Python class questions

2008-06-19 Thread Cédric Lucantis
Le Thursday 19 June 2008 13:54:03 John Dann, vous avez écrit : > A Python newbie, but some basic understanding of how classes, objects > etc work in eg VB.Net. However, I'm struggling a little to translate > this knowledge into the Python context. > > Maybe I could provide some outline code as an i

Simple Python class questions

2008-06-19 Thread John Dann
A Python newbie, but some basic understanding of how classes, objects etc work in eg VB.Net. However, I'm struggling a little to translate this knowledge into the Python context. I'm trying to teach myself this aspect of Python by working up a trial project, part of which calls for pulling in data

Re: Python Class Best Practice

2007-12-12 Thread MarkE
On 4 Dec, 23:18, Rod Person <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > I've been doing python programming for about 2 years as a hobby and now > I'm finally able to use it at work in an enterprise environment. Since > I will be creating the base classes and lib

Re: Python Class Best Practice

2007-12-07 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > On Dec 5, 12:18 am, Rod Person <[EMAIL PROTECTED]> wrote: >> -BEGIN PGP SIGNED MESSAGE- >> Hash: SHA1 >> >> I've been doing python programming for about 2 years as a hobby and now >> I'm finally able to use it at work in an enterprise environment. Since >> I wi

Re: Python Class Best Practice

2007-12-05 Thread cptnwillard
On Dec 5, 12:18 am, Rod Person <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > I've been doing python programming for about 2 years as a hobby and now > I'm finally able to use it at work in an enterprise environment. Since > I will be creating the base classes and

Re: Python Class Best Practice

2007-12-04 Thread Pavan Mishra
On Dec 5, 4:18 am, Rod Person <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > I've been doing python programming for about 2 years as a hobby and now > I'm finally able to use it at work in an enterprise environment. Since > I will be creating the base classes and l

Re: Python Class Best Practice

2007-12-04 Thread Rod Person
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Tue, 04 Dec 2007 15:51:18 -0800 Gary Herron <[EMAIL PROTECTED]> wrote: > Rod Person wrote: > > > > 1: > > class Foo(object): > > member1='' > > member2=0 > > > > def __init__(self,member1='',member2=0): > > self.member1 = member1 > >

Re: Python Class Best Practice

2007-12-04 Thread Gary Herron
Rod Person wrote: > I've been doing python programming for about 2 years as a hobby and now > I'm finally able to use it at work in an enterprise environment. Since > I will be creating the base classes and libraries I wondering which why > is consider best when creating python classes: > > 1: > cl

Python Class Best Practice

2007-12-04 Thread Rod Person
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I've been doing python programming for about 2 years as a hobby and now I'm finally able to use it at work in an enterprise environment. Since I will be creating the base classes and libraries I wondering which why is consider best when creating python

Re: python class methods identity?

2007-11-23 Thread Bruno Desthuilliers
Chris Mellon a écrit : > On Nov 23, 2007 1:29 AM, Roc Zhou <[EMAIL PROTECTED]> wrote: (snip) >>Since both "var" and "func" are the variable of the class object, and > > "members", not variables. > "attributes", not members !-) -- http://mail.python.org/mailman/listinfo/python-list

Re: python class methods identity?

2007-11-23 Thread Chris Mellon
On Nov 23, 2007 1:29 AM, Roc Zhou <[EMAIL PROTECTED]> wrote: > Hello, > > I'm now being confused by this segment of code: > >>> class Test: > ... var = 1 > ... def func(self): pass > ... > >>> x = Test() > >>> y = Test() > >>> x.var is y.var > True > >>> x.func is y.func > False > >>> id(x.

Re: python class methods identity?

2007-11-23 Thread limodou
On Nov 23, 2007 4:06 PM, Roc Zhou <[EMAIL PROTECTED]> wrote: > This is the result comes from the Linux. > > And the result from Windows is: > > >>> class Test: > var = 1 > def func(self): pass > >>> x = Test() > >>> y = Test() > >>> x.var is y.var > True > >>> x.func is y.func > False > >>>

Re: python class methods identity?

2007-11-23 Thread Roc Zhou
This is the result comes from the Linux. And the result from Windows is: >>> class Test: var = 1 def func(self): pass >>> x = Test() >>> y = Test() >>> x.var is y.var True >>> x.func is y.func False >>> id(x.var) 11228488 >>> id(y.var) 11228488 >>> id(x.func) 14430976 >>> id(y.func) 144336

python class methods identity?

2007-11-22 Thread Roc Zhou
Hello, I'm now being confused by this segment of code: >>> class Test: ... var = 1 ... def func(self): pass ... >>> x = Test() >>> y = Test() >>> x.var is y.var True >>> x.func is y.func False >>> id(x.var); id(y.var) 146132400 146132400 >>> id(x.func); id(y.func) -1208243388 -1208243388

Re: Automatic Generation of Python Class Files

2007-10-30 Thread Chris Mellon
On Oct 30, 2007 5:52 AM, Fuzzyman <[EMAIL PROTECTED]> wrote: > On Oct 29, 11:35 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > > Fuzzyman wrote: > > > On Oct 22, 6:43 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > > >> # Inherit from object. There's no reason to create old-style classes. > > > >

Re: Automatic Generation of Python Class Files

2007-10-30 Thread Fuzzyman
On Oct 29, 11:35 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > Fuzzyman wrote: > > On Oct 22, 6:43 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > >> # Inherit from object. There's no reason to create old-style classes. > > > We recently had to change an object pipeline from new style classes to

Re: Automatic Generation of Python Class Files

2007-10-30 Thread Hrvoje Niksic
Fuzzyman <[EMAIL PROTECTED]> writes: > We recently had to change an object pipeline from new style classes > to old style. A lot of these objects were being created and the > *extra overhead* of new style classes was killing us. :-) Can you please expand on this? What extra overhead of new-style

  1   2   3   >