Re: Automatic Generation of Python Class Files

2007-10-23 Thread Bruno Desthuilliers
Steven Bethard a écrit : > Bruno Desthuilliers wrote: > >>> I guess as long as your documentation is clear about which attributes >>> require computation and which don't... >> >> >> Why should it ? FWIW, I mentionned that I would obviously not use >> properties for values requiring heavy, non ca

Re: Automatic Generation of Python Class Files

2007-10-23 Thread Steven Bethard
Bruno Desthuilliers wrote: > Steven Bethard a écrit : >> Bruno Desthuilliers wrote: I guess as long as your documentation is clear about which attributes require computation and which don't... >>> >>> Why should it ? [snip] > I believe we simply disagree on weither properties should be u

Re: Automatic Generation of Python Class Files

2007-10-23 Thread Bruno Desthuilliers
Steven Bethard a écrit : > Bruno Desthuilliers wrote: > >> Steven Bethard a écrit : >> >>> Bruno Desthuilliers wrote: >>> > I guess as long as your documentation is clear about which > attributes require computation and which don't... Why should it ? > > [snip] > >> I bel

Re: Automatic Generation of Python Class Files

2007-10-23 Thread Steven Bethard
Bruno Desthuilliers wrote: > Now how does your desire for documentation imply that "if you're > creating a class for the first time, it should *never* use property()" ? Of course, there's *never* any such thing as "never" in Python. ;-) STeVe P.S. If you really don't understand what I was gett

Re: Automatic Generation of Python Class Files

2007-10-29 Thread Fuzzyman
; > [Methods] > > eatMaiden argMaiden > > fightKnight argKnight > > > Generated Python Class File: > > > def class FireBreathingDragon: > > >def getStrength(self): > > """ > > Docstring goes here. > > > @return

Re: Automatic Generation of Python Class Files

2007-10-29 Thread Steven Bethard
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 > old style. A lot of these objects were being created and the *extra

Re: Automatic Generation of Python Class Files

2007-10-30 Thread Bruno Desthuilliers
Fuzzyman a écrit : > On Oct 22, 6:43 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: (snip) >> # 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 > old style. A lot of these objects were being created an

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

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 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: 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

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

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

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: 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

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

ctypes:passing python class instances through c and back

2007-07-26 Thread m2i3k
Hi I have C code with requires me to register a python callback. I am able to get the callback working well using ctypes if I use global functions without any context argument for the callback. Now I want to register a python class member function for callback, and give "self" as t

include a python class in another python script.

2006-08-15 Thread KraftDiner
I have a class that is defined in a file called MyClass.py How do I use that class in another python script.. import MyClass ? (Does it need to be in a specific location?) -- http://mail.python.org/mailman/listinfo/python-list

Re: create a c++ wrapper for python class?

2006-05-10 Thread Diez B. Roggisch
Mark Harrison schrieb: > Right now I'm using Boost Python to wrap some C++ code so > that applications from both languages can use it. > > This is great, but I'm rapidly coming to the conclusion that > a lot of this work is better coded in Python. There's nothing > particularly CPU-bound, and the

Create new instance of Python class in C

2005-09-09 Thread Sybren Stuvel
Hi people, I'm creating a program that can solve and create Sudoku puzzles. My creation function needs to make a lot of copies of a puzzle. Until now, I used copy.deepcopy(), but that's too slow. I want to implement such a copying function in C and use that instead. My idea about this is: - Get t

Re: Embedding Python: Creating Python Class from Application

2006-01-12 Thread Kakacek
In the mean time I did this. It works however, it creates memory leaks. Any idea what could be wrong? procedure TForm1.PyCreateInstance(Sender: TObject; PSelf, Args: PPyObject; var Result: PPyObject); var BClassName: PChar; BInstName: PChar; // BB: Boolean; BModule: PPyObje

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

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: 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

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 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 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 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: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 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

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

Re: ctypes:passing python class instances through c and back

2007-07-29 Thread Gabriel Genellina
I want to register a python class member function for callback, > and give "self" as the context argument at the time of callback > registration. Then the c code can invoke the callback with self as the > context argument Use a bound method as the callback -that is, get the

Re: include a python class in another python script.

2006-08-15 Thread [EMAIL PROTECTED]
KraftDiner wrote: > I have a class that is defined in a file called MyClass.py > > How do I use that class in another python script.. > import MyClass ? (Does it need to be in a specific location?) Same directory as the script that's importing it, or in the PYTHONPATH. import sys print sys.path

Re: include a python class in another python script.

2006-08-15 Thread danielx
KraftDiner wrote: > I have a class that is defined in a file called MyClass.py > > How do I use that class in another python script.. > import MyClass ? (Does it need to be in a specific location?) MyClass.py has to be on your "python path". Your python path is a list of directories python will

Re: Create new instance of Python class in C

2005-09-09 Thread djw
Sybren Stuvel wrote: > Hi people, > > I'm creating a program that can solve and create Sudoku puzzles. My > creation function needs to make a lot of copies of a puzzle. Until > now, I used copy.deepcopy(), but that's too slow. I want to implement > such a copying function in C and use that instead

Re: Create new instance of Python class in C

2005-09-09 Thread Sybren Stuvel
djw enlightened us with: > Personally, I would try Psyco first, and consider Pyrex next. Ok, I'll take a look at those. > Are you sure your algorithm can't be optimized first, before you > start trying to write this in C? I'm sure there will be optimizations, but profiling showed that the copyin

Re: Create new instance of Python class in C

2005-09-09 Thread phil hunt
On Fri, 9 Sep 2005 17:19:21 +0200, Sybren Stuvel <[EMAIL PROTECTED]> wrote: >Hi people, > >I'm creating a program that can solve and create Sudoku puzzles. My >creation function needs to make a lot of copies of a puzzle. Why do you need to maske lots of copies? And when you say "lots of" what numb

Re: Create new instance of Python class in C

2005-09-09 Thread phil hunt
On Fri, 9 Sep 2005 18:50:26 +0200, Sybren Stuvel <[EMAIL PROTECTED]> wrote: >djw enlightened us with: >> Personally, I would try Psyco first, and consider Pyrex next. > >Ok, I'll take a look at those. > >> Are you sure your algorithm can't be optimized first, before you >> start trying to write thi

Re: Create new instance of Python class in C

2005-09-10 Thread Sybren Stuvel
phil hunt enlightened us with: > Why do you need to maske lots of copies? The puzzles are stored in a NxN list of strings. The strings contain all the numerals that that block can contain. So a 9x9 puzzle contains 81 strings "123456789" when it's "empty". My creation function picks a block that i

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

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 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
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-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-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 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 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 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-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

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

graphical or flow charting design aid for python class development?

2005-08-31 Thread William Gill
Being somewhat new to Python, and having a tendency to over complicate things in my class design, I was wondering if anyone can suggest a simple graphical or flowcharting tool that they use to organize their class and program design? Because of a 55 mph head-on accident a few years back, I ha

using vim as a python class/module/function etc.. browser

2006-04-10 Thread Chris Jones
I'm trying to make sense of a python program and was wondering if vim has any python-oriented functionalities (apart from syntax highlighting) that would make it somewhat easier to browse the source code. What I had in mind is something that would let me use CTRL+] to automatically display what

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: graphical or flow charting design aid for python class development?

2005-08-31 Thread tooper
You may want to use Doxygen, which generates nice diagrams. It's normally only for C++, but there are nice filters (for ex. http://i31www.ira.uka.de/~baas/pydoxy) that generates C++ header from python code that Doxygen can crunch. Another solution is to use IDE such as Eric3 that can generate UML

Re: graphical or flow charting design aid for python class development?

2005-08-31 Thread gene tani
Have you looked at class browser module? Not the graphical tool you're looking for, but maybe a good start http://www.python.org/doc/2.0.1/lib/module-pyclbr.html William Gill wrote: > Being somewhat new to Python, and having a tendency to over complicate > things in my class design, I was wonder

Re: graphical or flow charting design aid for python class development?

2005-08-31 Thread William Gill
gene tani wrote: > Have you looked at class browser module? Not the graphical tool you're > looking for, but maybe a good start No, it's not graphical, but it looks like I may be able to use it to put together a nice outline, or summary of my modules. It's worth exploring, thanks. Bill >

Re: graphical or flow charting design aid for python class development?

2005-08-31 Thread William Gill
On first glance Doxygen doesn't look like the ticket, but the screen shots of Eric3 look VERY promising. I have already downloaded it, and will try it. Thanks, Bill tooper wrote: > You may want to use Doxygen, which generates nice diagrams. It's > normally only for C++, but there are nice filt

Re: graphical or flow charting design aid for python class development?

2005-08-31 Thread Michael Ekstrand
On Wed, 31 Aug 2005 15:40:52 GMT William Gill <[EMAIL PROTECTED]> wrote: > Being somewhat new to Python, and having a tendency to over > complicate things in my class design, I was wondering if anyone can > suggest a simple graphical or flowcharting tool that they use to > organize their class and

Re: graphical or flow charting design aid for python class development?

2005-08-31 Thread gene tani
forgot mention Komodo's code and object browser, which're both in the $30 license http://aspn.activestate.com/ASPN/docs/Komodo/3.1/komodo-doc-codeintel.html#codeintel_codebrowser and SPE's supposed to have some kinda class explorer http://www.stani.be/python/spe -- http://mail.python.org/mailma

Re: graphical or flow charting design aid for python class development?

2005-09-01 Thread Paul McGuire
It's not free, but it is pretty cheap considering all it can do. Check out Enterprise Architect (with the free add-in for Python) from www.sparxsystems.com.au. Pro version license is US$180 or so, but they may have a student license for less that you could use. -- Paul -- http://mail.python.or

Re: graphical or flow charting design aid for python class development?

2005-09-01 Thread William Gill
Thanks everyone. I will explore all the suggestions, but it looks like SPE is the immediate answer. Bill William Gill wrote: > Being somewhat new to Python, and having a tendency to over complicate > things in my class design, I was wondering if anyone can suggest a > simple graphical or flow

Re: graphical or flow charting design aid for python class development?

2005-09-01 Thread gene tani
There's also this about giving source/class browsers a hand by sprinkling "isinstance()"'s in http://wingware.com/doc/intro/tutorial-sassist-with-classes I always encourage people to write up their experience/improessions in the python wiki: http://wiki.python.org/moin/PythonEditors (or the sepa

Re: graphical or flow charting design aid for python class development?

2005-09-01 Thread Florian Diesch
William Gill <[EMAIL PROTECTED]> wrote: > Being somewhat new to Python, and having a tendency to over complicate > things in my class design, I was wondering if anyone can suggest a > simple graphical or flowcharting tool that they use to organize their > class and program design? Because of a

Re: using vim as a python class/module/function etc.. browser

2006-04-10 Thread Robert Kern
Chris Jones wrote: > I'm trying to make sense of a python program and was wondering if vim > has any python-oriented functionalities (apart from syntax highlighting) > that would make it somewhat easier to browse the source code. > > What I had in mind is something that would let me use CTRL+] t

Re: using vim as a python class/module/function etc.. browser

2006-04-10 Thread Chris Jones
Robert Kern wrote: > Chris Jones wrote: > >>I'm trying to make sense of a python program and was wondering if vim >>has any python-oriented functionalities (apart from syntax highlighting) >>that would make it somewhat easier to browse the source code. >> >>What I had in mind is something that w

Re: using vim as a python class/module/function etc.. browser

2006-04-10 Thread Robert Kern
Chris Jones wrote: > Robert Kern wrote: >>Of course, modern versions of Exuberant Ctags also support Python, too. > > I apt-installed this package but the man page is rather intimidating so > I thought I might as well make sure I was going in the right direction. You will probably want to read

Re: using vim as a python class/module/function etc.. browser

2006-04-11 Thread Daniel Nogradi
> >>Of course, modern versions of Exuberant Ctags also support Python, too. > > > > I apt-installed this package but the man page is rather intimidating so > > I thought I might as well make sure I was going in the right direction. > > You will probably want to read the vim documentation on how to

Re: using vim as a python class/module/function etc.. browser

2006-04-11 Thread Chris Jones
Daniel Nogradi wrote: Of course, modern versions of Exuberant Ctags also support Python, too. >>> >>>I apt-installed this package but the man page is rather intimidating so >>>I thought I might as well make sure I was going in the right direction. >> >>You will probably want to read the vim doc

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: 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

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

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

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

A Comparison of Python Class Objects and Init Files for Program Configuration

2006-09-12 Thread metaperl
A Comparison of Python Class Objects and Init Files for Program Configuration = Terrence Brannon [EMAIL PROTECTED] http://www.livingcosmos.org/Members/sundevil/python/articles/a-comparison-of-python-class-objects-and-init

Why does python class have not private methods? Will this never changed?

2005-04-19 Thread could ildg
Python is an oop language, but why does it hava not private methods? And it even has not real private fields. Will this never changed? Private stuff always makes programming much easier. -- 鹦鹉聪明绝顶、搞笑之极,是人类的好朋友。 直到有一天,我才发觉,我是鹦鹉。 我是翻墙的鹦鹉。 -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does python class have not private methods? Will this neverchanged?

2005-04-19 Thread Fredrik Lundh
"could ildg" <[EMAIL PROTECTED]> wrote: > Private stuff always makes programming much easier. says who? -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does python class have not private methods? Will this neverchanged?

2005-04-19 Thread James
Trolls? On 4/19/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > "could ildg" <[EMAIL PROTECTED]> wrote: > > > Private stuff always makes programming much easier. > > says who? > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-l

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

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-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 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, 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 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-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-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 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

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 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 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 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

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 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 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: Why does python class have not private methods? Will this never changed?

2005-04-19 Thread Simon Brunning
On 4/19/05, could ildg <[EMAIL PROTECTED]> wrote: > Python is an oop language, Yes. > Private stuff always makes programming much easier. That contention is, at best, debatable. See http://groups-beta.google.com/group/comp.lang.python/msg/b977ed1312e10b21. -- Cheers, Simon B, [EMAIL PROTECTED]

Re: Why does python class have not private methods? Will this never changed?

2005-04-19 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Simon Brunning <[EMAIL PROTECTED]> wrote: > On 4/19/05, could ildg <[EMAIL PROTECTED]> wrote: > > Python is an oop language, > > Yes. > > > Private stuff always makes programming much easier. > > That contention is, at best, debatable. See > http://groups-beta.g

Re: Why does python class have not private methods? Will this never changed?

2005-04-19 Thread Peter Hansen
Roy Smith wrote: Simon Brunning <[EMAIL PROTECTED]> wrote: On 4/19/05, could ildg <[EMAIL PROTECTED]> wrote: Private stuff always makes programming much easier. That contention is, at best, debatable. See http://groups-beta.google.com/group/comp.lang.python/msg/b977ed1312e10b21. Nice essay. Now,

Re: Why does python class have not private methods? Will this never changed?

2005-04-19 Thread Jaime Wyant
Have I missed something? Doesn't this mangle class methods: class Foo: def __bar(self): print "bar" Granted, you could probably figure out how the names are being mangled. In the example above __bar is a defacto private method. Griping about it not having `private' in front of it is asin

Re: Why does python class have not private methods? Will this never changed?

2005-04-19 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Peter Hansen <[EMAIL PROTECTED]> wrote: >Roy Smith wrote: >> Simon Brunning <[EMAIL PROTECTED]> wrote: >>>On 4/19/05, could ildg <[EMAIL PROTECTED]> wrote: Private stuff always makes programming much easier. >>> >>>That contention is, at best, debatable. See >>

Re: Why does python class have not private methods? Will this never changed?

2005-04-19 Thread Adriano Ferreira
>but why does it hava not private methods? Because it does not need them, ain't it? >Private stuff always makes programming much easier. Does it? Sometimes contortion is needed to get rid of declarations that restrain access, for example, when writing tests. I think the point-of-view of Python is

Python class method as an argument of a function in a C extension

2007-09-26 Thread mauro
Hi all, I am trying to wrap some C code using SWIG (win32, mingw). I am new to SWIG and to the Python/C API so what I am doing is looking at the examples and trying to fit them to my needs, but I cannot find any complete demo example of a C function taking as an argument a Python function defined

<    1   2   3   >