Re: Events in Python

2008-01-30 Thread Ivan Illarionov
You may need Louie (http://louie.berlios.de) Django (http://djangoproject.com) does the same in django.dispatch - and Django version works about 33% faster. Note that all those signals/events are very slow in Python. --Ivan -- http://mail.python.org/mailman/listinfo/python-list

Re: Events in Python

2008-01-30 Thread Ivan Illarionov
> Compared to what, did you measure something? As example, instantiation of Model classes in Django (Model.__init__) sends two signals (pre_init and post_init) - they are rarely used in practice - but they make instantiation about two times slower. Yes, I measured that. The creator of Louie (Patr

Re: REALLY simple xml reader

2008-01-30 Thread Ivan Illarionov
>>> from xml.etree import ElementTree as et >>> from decimal import Decimal >>> >>> root = et.parse('file/with/your.xml') >>> debits = dict((debit.attrib['category'], >>> Decimal(debit.find('amount').text)) for debit in root.findall('debit')) >>> >>> for cat, amount in debits.items(): ... print

Re: REALLY simple xml reader

2008-01-31 Thread Ivan Illarionov
> Also, for XML documents, they were probably thinking that the > documents will be machine-generated most of the time. As far as I can > tell, they were right in that. If anybody has to deal with human-generated XML/HTML in Python it may be better to use something like http://www.crummy.com/softw

Re: Does anyone else use this little idiom?

2008-02-03 Thread Ivan Illarionov
Plain Python function are very often more powerful than classes: >>> def go(count): ... if not hasattr(go, 'count'): ... go.count = count ... if go.count <= 0: ... del go.count ... return False ... go.count -= 1 ... return True ... >>> while go(3): ... print 'hello' ... hello

Re: fast method accessing large, simple structured data

2008-02-03 Thread Ivan Illarionov
> Is there some good format that is optimized for search for > just 1 attribute (title) and then returning the corresponding article? I would use Durus (http://www.mems-exchange.org/software/durus/) - simple pythonic object database - and store this data as persistent python dict with Title keys a

Re: Does anyone else use this little idiom?

2008-02-03 Thread Ivan Illarionov
On Feb 4, 12:56 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Sun, 03 Feb 2008 05:33:16 -0800, Ivan Illarionov wrote: > > Plain Python function are very often more powerful than classes: > > >>>> def go(count): > > ... if not h

Re: Double underscores -- ugly?

2008-02-19 Thread Ivan Illarionov
I would like to see something like %init or &init to be converted to __init__ behind the scenes. And $something to be converted to self.something. But, unfortunately, most Python people would consider this ugly just because Perl uses too much syntactic sugar and anything Perl-like is considered ugl

Re: Hyphenation module PyHyphen-0.3 released

2008-02-24 Thread Ivan Illarionov
> I don't know if I'm just doing it wrong, or if I can't use extensions > compiled with mingw32 with the standard distribution Python > executable? I was able to install on Windows XP with mingw: setup.py build -c mingw32 setup.py install --skip-build It works fine with English dictionary, but h

Re: struct unpack

2008-03-17 Thread Ivan Illarionov
On Mar 17, 11:00 pm, brnstrmrs <[EMAIL PROTECTED]> wrote: > If I run: > > testValue = '\x02\x00' > junk = struct.unpack('h', testValue) > > Everything works but If I run > > testValue = raw_input("Enter Binary Code..:") inputting at the > console '\x02\x00' > junk = struct.unpack('h', testValue) >

Re: Interesting math problem

2008-03-17 Thread Ivan Illarionov
On Mar 18, 1:24 am, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: > Here is an interesting math problem: > > You have a number X > 0 and another number Y > 0. The goal is to > divide X into a list with length Y. Each item in the list is an > integer. The sum of all integers is X. Each integer is eit

Re: Fast 2D Raster Rendering with GUI

2008-03-17 Thread Ivan Illarionov
On Mar 18, 4:36 am, dave <[EMAIL PROTECTED]> wrote: > Hi All. I've been formulating in my head a simple image editor. I > actually started prototyping is some time ago in Java, but am liking > Python more and more. My editor will be nowhere near the level of Gimp/ > Photoshop, but I do need fast pi

Re: Fast 2D Raster Rendering with GUI

2008-03-18 Thread Ivan Illarionov
On Mar 19, 2:33 am, dave <[EMAIL PROTECTED]> wrote: > First I want to say thank you all for your timely replies. This is all > good food for thought. I've been programming more many years, but fast > graphics rendering is new territory for me. > > I'm hoping to fine something like a buffer_blit, wh

Re: Fast 2D Raster Rendering with GUI

2008-03-18 Thread Ivan Illarionov
> That's another new step for me. Any ideas where to start? http://docs.python.org/ext/simpleExample.html And look into the source of existing extensions. PIL and PyCairo are the best in your situation. -- http://mail.python.org/mailman/listinfo/python-list

Re: 'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-01-13 Thread Ivan Illarionov
Ben Sizer wrote: > What am I doing wrong? What are you trying to achieve? If you want to modify sys.path I suggest using Python/C API directly: (boilerplate removed) PyImport_ImportModule("sys") PyObject_GetAttrString(sysmod_pointer, "path") PyList_Insert(pathobj_pointer, 0, path_python_str) --

Re: 'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-01-14 Thread Ivan Illarionov
On Jan 14, 1:49 pm, Ben Sizer wrote: > No, I don't want to do anything with sys.path apart from see it. I > just wanted my original question answered, not a guess at my intent > and a solution for something I'm not doing. ;)  Thanks though! > > Again - why can I not reference sys from within the f

Re: 'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-01-14 Thread Ivan Illarionov
On Jan 14, 8:00 pm, Ben Sizer wrote: > I will try it when I get home. However I would like to be able to > treat them as separate dictionaries, as I want to be able to import > some symbols and modules at a global level, but be able to clear out > objects introduced at the local level on a periodi

Re: 'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-01-14 Thread Ivan Illarionov
On Jan 14, 8:17 pm, Ivan Illarionov wrote: > On Jan 14, 8:00 pm, Ben Sizer wrote: > > > I will try it when I get home. However I would like to be able to > > treat them as separate dictionaries, as I want to be able to import > > some symbols and modules at a global lev

Re: v = json.loads("{'test':'test'}")

2009-01-26 Thread Ivan Illarionov
Diez wrote: > gert schrieb: > > Single quotes works in every browser that support json so i > > recommended python should support it too, besides it looks much > > cleaner > > {'test': 'test'} > > {"test": "test"} > > > It can not be that hard to support both notation can it ? > > It's not hard, bu

Re: Does the Python community really follow the philospy of "Community Matters?"

2009-01-30 Thread Ivan Illarionov
r wrote: > Where are the community projects supporting Python? -- besides the > core devlopment. Seem s that nobody is interested unless their pay-pal > account is involved. I find this all quite disappointing. Hi r, Can you just type import antigravity and join us up there? Hatred for Ruby

Re: Catching Python exceptions in C

2008-12-09 Thread Ivan Illarionov
On Dec 8, 9:42 pm, Senthil Kumar <[EMAIL PROTECTED]> wrote: > Hi Pythoneers ! > Can somebody give a quick solution? > I am trying to raise exceptions in python and trying to handle it in > C. > I am able to raise exceptions successfully. However could not catch > those in C. > I am using the follow

Re: Catching Python exceptions in C

2008-12-09 Thread Ivan Illarionov
On Dec 9, 12:33 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > On Dec 8, 9:42 pm, Senthil Kumar <[EMAIL PROTECTED]> wrote: > > > Hi Pythoneers ! > > Can somebody give a quick solution? > > I am trying to raise exceptions in python and trying to handle

Re: Beginner trying to understand functions.

2008-12-09 Thread Ivan Illarionov
On Dec 8, 9:02 pm, simonh <[EMAIL PROTECTED]> wrote: > Thanks for the many replies. Thanks especially to Pierre. This works > perfectly: > def getAge(): >     while True: >         try: >             age = int(input('Please enter your age: ')) >             return age > >         except ValueErr

Re: Memory leak when using a C++ module for Python

2008-12-16 Thread Ivan Illarionov
On Dec 11, 8:35 pm, Jaume Bonet wrote: >         //Here we take the info coming from python and transform it > into a vector (will allow us to work with numbers instead of >         // strings) and shareInt which is an array of sets (form > std::set) >         vector translator = string2int > (sh

Re: How to modify a program while it's running?

2008-12-16 Thread Ivan Illarionov
On Dec 16, 11:25 pm, Joe Strout wrote: > Here's my situation: I'm making an AIM bot, but the AIM server will   > get annoyed if you log in too frequently (and then lock you out for a   > while).  So my usual build-a-little, test-a-little methodology doesn't   > work too well. > > So I'd like to re

Re: C API and memory allocation

2008-12-18 Thread Ivan Illarionov
On 18 дек, 03:51, Aaron Brady wrote: (snip) > How did you get a reference to the original > string object, with which to increment its reference count? Use the "O!" format instead of "s": PyObject *pystr; ... PyArg_ParseTuple(args, "O!", &PyStringObject, &pystr) ... Then you can use PyString_AS

Re: C API and memory allocation

2008-12-18 Thread Ivan Illarionov
On 18 дек, 14:09, Ivan Illarionov wrote: > ... PyArg_ParseTuple(args, "O!", &PyStringObject, &pystr) ... Sorry, I must have said &PyString_Type, not &PyStringObject -- http://mail.python.org/mailman/listinfo/python-list

Re: PIL - font kerning

2008-12-23 Thread Ivan Illarionov
On 23 дек, 16:44, carsn wrote: > Hey all, > > anybody know, if there´s a way to specify the kerning of a font, when > you draw text with PIL? > > I´d like to achieve the same effect that you get, when you set a > negative kerning in Gimp/Photshop - ie. reduce the spacing between > glyphs. > > Can

Re: PIL - font kerning

2008-12-23 Thread Ivan Illarionov
On Dec 23, 11:22 pm, Ivan Illarionov wrote: > On 23 дек, 16:44, carsn wrote: > > > Hey all, > > > anybody know, if there´s a way to specify the kerning of a font, when > > you draw text with PIL? > > > I´d like to achieve the same effect that you get, when yo

Re: Beep

2008-12-23 Thread Ivan Illarionov
On Dec 22, 3:16 am, Jeffrey Barish wrote: > I use sys.stdout.write('\a') to beep.  It works fine on Kubuntu, but not on > two other platforms (one of which is Ubuntu).  I presume that the problem > is due to a system configuration issue.  Can someone point me in the right > direction?  Thanks. > -

Re: Custom C Exception Subclasses

2008-12-24 Thread Ivan Illarionov
On Dec 24, 6:42 pm, Ross wrote: > For a project that I am doing, it would be useful to have an exception > class that stores some additional data along with the message. > However, I want to be able to store a couple pointers to C++ classes, > so I can't just use an exception created with PyExc_Ne

Re: Custom C Exception Subclasses

2008-12-24 Thread Ivan Illarionov
On Dec 24, 10:43 pm, "Gabriel Genellina" wrote: > En Wed, 24 Dec 2008 15:48:34 -0200, Gabriel Genellina   > escribió: > > > En Wed, 24 Dec 2008 15:00:36 -0200, Ivan Illarionov   > > escribió: > > >> When you raise an exception in C++ you can set it to

Re: C API: array of floats/ints from python to C and back

2008-12-27 Thread Ivan Illarionov
On Dec 28, 12:45 am, "Daniel Fetchinson" wrote: > I'm trying to write an extension module in C which contains a single > function with the following prototype: > > void func( int N, int * arg1, int * arg2, int * ret ); > > Here arg1 and arg2 are length N arrays, and the function computes ret > whi

Re: Is there a programming language that is combination of Python and Basic?

2009-04-21 Thread Ivan Illarionov
On Apr 18, 3:39 pm, BJörn Lindqvist wrote: > I first started programming basic and i don't think it has hurt me much. > > I can somewhat sympathise with the op, neither python nor any other > mainstream language can still do this: > > SCREEN 13 > PSET 160,100,255 This is not true. It's trivial wi

Re: Is using range() in for loops really Pythonic?

2008-05-11 Thread Ivan Illarionov
On Sun, 11 May 2008 18:52:48 -0700, Carl Banks wrote: > On May 11, 6:44 pm, Ben Finney <[EMAIL PROTECTED]> > wrote: >> In such cases, the name 'dummy' is conventionally bound to the items >> from the iterator, for clarity of purpose:: >> >> for dummy in range(10): >> # do stuff that ma

Re: Is using range() in for loops really Pythonic?

2008-05-11 Thread Ivan Illarionov
>> In such cases, the name 'dummy' is conventionally bound to the items >> from the iterator, for clarity of purpose [..] > If a value isn't used, then I think the most clear name for it is > "unused". [...] Maybe my brain works differently, but I find both "dummy" and "unused" are extremely conf

Re: Is using range() in for loops really Pythonic?

2008-05-12 Thread Ivan Illarionov
On Mon, 12 May 2008 16:24:23 +1000, Ben Finney wrote: [...] > That is also regrettably common in Python code. It still suffers from > being unnecessarily ambiguous, since there are *also* plenty of loops > using 'i', 'j', etc. where the loop counter *is* used. > > Differentiating these use cases b

Re: Is using range() in for loops really Pythonic?

2008-05-12 Thread Ivan Illarionov
>> On Mon, 12 May 2008 16:24:23 +1000, Ben Finney wrote: [...] >> > That is also regrettably common in Python code. It still suffers from >> > being unnecessarily ambiguous, since there are *also* plenty of loops >> > using 'i', 'j', etc. where the loop counter *is* used. >> > >> > Differentiating

Re: how to get information of a running prog in python

2008-05-12 Thread Ivan Illarionov
On Mon, 12 May 2008 19:19:05 -0700, Jimmy wrote: > Well, i know it may be a little non-python thing, however, I can think > of no place better to post this question :) > > can anyone tell me, in python, how to obtain some information of a > running program? > paticularly, if i am playing some mus

Re: how to get information of a running prog in python

2008-05-12 Thread Ivan Illarionov
On Mon, 12 May 2008 20:29:46 -0700, George Sakkis wrote: > On May 12, 11:02 pm, Jimmy <[EMAIL PROTECTED]> wrote: >> On May 13, 10:36 am, "Dan Upton" <[EMAIL PROTECTED]> wrote: >> >> >> >> > On Mon, May 12, 2008 at 10:19 PM, Jimmy <[EMAIL PROTECTED]> >> > wrote: >> > > Well, i know it may be a litt

Re: usage of python

2008-05-13 Thread Ivan Illarionov
On 13 май, 21:10, Rajarshi <[EMAIL PROTECTED]> wrote: > Hi, I teach an introductory programming course in Python. As part of > the introduction I'd like to highlight the usage of Python in > industry. The idea is to show that there are big players using Python > for a variety of tasks. Given that t

Re: Class Methods Vs Any Other Callable

2008-05-14 Thread Ivan Illarionov
On Wed, 14 May 2008 09:21:10 -0700, vbgunz wrote: > [...] > when you see > one, what is the first thing that comes to mind? When you write one, > what was the first thing on your mind? Other than "similar to static- > methods", at what point will you be glad you used one? To sum it up, > what is t

Re: addendum Re: working with images (PIL ?)

2008-05-16 Thread Ivan Illarionov
On Wed, 14 May 2008 14:35:25 -0400, Poppy wrote: > I've put together some code to demonstrate what my goal is though > looping pixel by pixel it's rather slow. > > import Image > > def check_whitespace(): > im = Image.open("server\\vol\\temp\\image.jpg") > > size = im.size > >

Re: writing python extensions in assembly

2008-05-16 Thread Ivan Illarionov
On Fri, 16 May 2008 10:13:04 -0400, inhahe wrote: > Can anyone give me pointers/instructions/a template for writing a Python > extension in assembly (or better, HLA)? Look up pygame sources. They have some hot inline MMX stuff. I experimented with this rescently and I must admit that it's etremel

Classmethods are evil

2008-05-16 Thread Ivan Illarionov
After re-reading "Python is not Java" I finally came to conclusion that classmethods in Python are a very Bad Thing. I can't see any use-case of them that couldn't be re-written more clearly with methods of metaclass or plain functions. They have the following issues: 1. You mix instance-level

Re: Classmethods are evil

2008-05-17 Thread Ivan Illarionov
On Sat, 17 May 2008 02:33:13 -0300, Gabriel Genellina wrote: > En Sat, 17 May 2008 01:01:50 -0300, Ivan Illarionov > <[EMAIL PROTECTED]> escribió: > >> After re-reading "Python is not Java" I finally came to conclusion that >> classmethods in Python are a

Re: morning in Python

2008-05-17 Thread Ivan Illarionov
On Sat, 17 May 2008 02:57:08 -0700, castironpi wrote: > Full day later, I think it, to emphasize state, would prioritize > context. The reason for the huge ramble was, believe it or not, > namespace conflict... as though any other states around here might nose > in. And thanks to 'inhahe' for co

Re: morning in Python

2008-05-18 Thread Ivan Illarionov
On Sun, 18 May 2008 11:15:06 +0200, Martin v. Löwis wrote: > There is also the issue of aliases. Some call it Moscow, some Moskau, > when it is really called Москва. Of course, the same issue exists for > states: some call it Kalifornien, others California. I don't see any issues here. Everybody

Re: addendum Re: working with images (PIL ?)

2008-05-20 Thread Ivan Illarionov
On Mon, 19 May 2008 10:18:00 -0400, Poppy wrote: > Thanks, since posting I figured out how to interpret the histogram > results, which seems to be the consensus in responses. I wrote a check > image program and have been periodically calling it against a folder > where I make a copy of our images

Re: Using Python for programming algorithms

2008-05-20 Thread Ivan Illarionov
On Mon, 19 May 2008 08:53:11 -0700, Henrique Dante de Almeida wrote: > On May 19, 6:52 am, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: >> Henrique Dante de Almeida a écrit : >> >> > On May 17, 7:32 pm, Vicent Giner <[EMAIL PROTECTED]> wrote: >> >> Hello. >> >> (snip) >> >> However, it is usuall

Re: Using Python for programming algorithms

2008-05-20 Thread Ivan Illarionov
On Mon, 19 May 2008 11:07:06 -0700, Vicent Giner wrote: [...] > > By the way, is it possible (and easy) to call a C function from a Python > program?? Yes. http://groups.google.com/group/comp.lang.python/msg/9d47913a265c348a -- Ivan -- http://mail.python.org/mailman/listinfo/python-list

Re: Classmethods are evil

2008-05-20 Thread Ivan Illarionov
On Mon, 19 May 2008 13:53:31 -0700, [EMAIL PROTECTED] wrote: > On 17 mai, 11:50, Ivan Illarionov <[EMAIL PROTECTED]> wrote: >> On Sat, 17 May 2008 02:33:13 -0300, Gabriel Genellina wrote: >> > En Sat, 17 May 2008 01:01:50 -0300, Ivan Illarionov >> > <[EMAIL PRO

Re: Producing multiple items in a list comprehension

2008-05-22 Thread Ivan Illarionov
On Thu, 22 May 2008 15:29:42 -0400, inhahe wrote: > "Joel Koltner" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Is there an easy way to get a list comprehension to produce a flat list >> of, say, [x,2*x] for each input argument? >> >> E.g., I'd like to do something like: >> >>

Re: 2 different versions of python compiling files.

2008-05-23 Thread Ivan Illarionov
> The original .py will always be there but you know what, multiple python > versions from different computers do access that one library at the same > time. > > Anyone know a possible solution ? What about subversion or mercurial and separate copies of your library for each Python version? --

Re: Python is slow

2008-05-23 Thread Ivan Illarionov
On 23 май, 02:20, Brad <[EMAIL PROTECTED]> wrote: > cm_gui wrote: > > Python is slow. > > It ain't C++, but it ain't a punch card either... somewhere in between. > I find it suitable for lots of stuff. I use C++ when performance really > matters tho... right tool for the job. Learn a good interp

Re: can python do some kernel stuff?

2008-05-23 Thread Ivan Illarionov
On 23 май, 22:32, Jimmy <[EMAIL PROTECTED]> wrote: [...] > however, how can I just simply know a key is pressed? If you are on Linux, use XLib http://python-xlib.sourceforge.net/ You need to catch the KeyPress or KeyRelease X events. while 1: ev = display.next_event() if ev.type == X.KeyP

Re: Python is slow

2008-05-24 Thread Ivan Illarionov
On Fri, 23 May 2008 22:56:57 -0700, cm_gui wrote: > i am not comparing Python with C or C++ which are of course compiled > languages. > > if there is any consolation to Python lovers here, Python is still > faster than Microsoft ASP/ASPX. > > i'm not trying to 'troll' here. it's not just me. m

Re: Newbie Question: How to use a .pth file on a Macintosh

2008-05-25 Thread Ivan Illarionov
Robbie wrote: > I can't seem to figure out where to put this file so that Python will > recognize it when I start it up. You need to put this file in your site-packages directory. To get the location of your site-packages directory, type in Python interactive shell: from distutils.sysconfig impo

Re: Getting a set of lambda functions

2008-05-25 Thread Ivan Illarionov
On Sun, 25 May 2008 13:43:15 +0200, Martin Manns wrote: > Hi, > > I try to get a set of lambda functions that allows me executing each > function code exactly once. Therefore, I would like to modify the set > function to compare the func_code properties (or the lambda functions to > use this prop

Re: Getting a set of lambda functions

2008-05-25 Thread Ivan Illarionov
On Sun, 25 May 2008 13:43:15 +0200, Martin Manns wrote: > Hi, > > I try to get a set of lambda functions that allows me executing each > function code exactly once. Therefore, I would like to modify the set > function to compare the func_code properties (or the lambda functions to > use this prop

Re: php vs python

2008-05-25 Thread Ivan Illarionov
Jerry Stuckle wrote: > Lie wrote: > > On May 22, 12:28 pm, NC <[EMAIL PROTECTED]> wrote: > >> On May 21, 1:10 pm, notbob <[EMAIL PROTECTED]> wrote: > >>> So, here's my delimna: I want to start a blog.  Yeah, who doesn't. > >>> Yet, I want learn the guts of it instead of just booting up some > >>> w

Re: php vs python

2008-05-25 Thread Ivan Illarionov
On Sun, 25 May 2008 13:28:25 -0700, NC wrote: [...] > A quick look at the revision log: > > http://byteflow.su/log/ > > reveals that the initial commit of 60 or so files has been done on > 08/14/07 > (10 months ago), a second developer came on board 12/01/07 (seven+ > months ago), > a third one,

Re: php vs python

2008-05-25 Thread Ivan Illarionov
On Sun, 25 May 2008 17:09:43 -0400, Jerry Stuckle wrote: > Not at all. I do it every day. > > And BTW - yes, I write Python, also. But I find I can write better, > faster code in PHP. I find I can write better code in Python. Maybe it's just a matter of personal preference? > Do you write PHP

Re: php vs python

2008-05-25 Thread Ivan Illarionov
On Sun, 25 May 2008 16:23:12 -0700, NC wrote: >> I didn't say that it's not possible to write good code in PHP, > > Indeed you didn't. You did, however, say that development in Python/ > Django is inherently faster than development in PHP (your exact words > were, "2 man/year in PHP == 2 man/wee

Re: php vs python

2008-05-25 Thread Ivan Illarionov
Jerry Stuckle wrote: > As I've said before - good programmers can write good code in any > language. Yes, they can. But it may be harder to do for them in one language and easier in another. Ivan -- http://mail.python.org/mailman/listinfo/python-list

Re: php vs python

2008-05-25 Thread Ivan Illarionov
On Sun, 25 May 2008 20:53:28 -0400, Jerry Stuckle wrote: > Ivan Illarionov wrote: >> Jerry Stuckle wrote: >> >>> As I've said before - good programmers can write good code in any >>> language. >> >> Yes, they can. But it may be harder to do

Re: php vs python

2008-05-27 Thread Ivan Illarionov
On Wed, 28 May 2008 05:10:20 +0400, AnrDaemon wrote: > Greetings, Ivan Illarionov. > In reply to Your message dated Monday, May 26, 2008, 04:47:00, > >>> As I've said before - good programmers can write good code in any >>> language. > >> Yes, they ca

Re: php vs python

2008-05-27 Thread Ivan Illarionov
On Wed, 28 May 2008 01:32:24 +, Ivan Illarionov wrote: > On Wed, 28 May 2008 05:10:20 +0400, AnrDaemon wrote: > >> Greetings, Ivan Illarionov. >> In reply to Your message dated Monday, May 26, 2008, 04:47:00, >> >>>> As I've said before - go

Re: php vs python

2008-05-27 Thread Ivan Illarionov
On Tue, 27 May 2008 21:47:55 -0400, Jerry Stuckle wrote: > Ivan Illarionov wrote: >> On Wed, 28 May 2008 05:10:20 +0400, AnrDaemon wrote: >> >>> Greetings, Ivan Illarionov. >>> In reply to Your message dated Monday, May 26, 2008, 04:47:00, >>> >&g

Re: php vs python

2008-05-27 Thread Ivan Illarionov
On Tue, 27 May 2008 22:27:40 -0400, Jerry Stuckle wrote: > Ivan Illarionov wrote: >> On Tue, 27 May 2008 21:47:55 -0400, Jerry Stuckle wrote: >> >>> Ivan Illarionov wrote: >>>> On Wed, 28 May 2008 05:10:20 +0400, AnrDaemon wrote: >>>> >>

Re: php vs python

2008-05-28 Thread Ivan Illarionov
On Wed, 28 May 2008 06:04:54 +, Tim Roberts wrote: > Ivan Illarionov <[EMAIL PROTECTED]> wrote: >>On Wed, 28 May 2008 05:10:20 +0400, AnrDaemon wrote: >>> In reply to Your message dated Monday, May 26, 2008, 04:47:00, >>> >>>>> As I've

Re: Best way to modify code without breaking stuff.

2008-06-04 Thread Ivan Illarionov
On Wed, 04 Jun 2008 00:25:19 -0700, Jesse Aldridge wrote: > I've got a module that I use regularly. I want to make some extensive > changes to this module but I want all of the programs that depend on the > module to keep working while I'm making my changes. What's the best way > to accomplish t

Re: printf in python

2008-06-04 Thread Ivan Illarionov
On Mon, 02 Jun 2008 00:32:33 -0700, gianluca wrote: > Hy, I've a problem with may python library generated with swig from C > code. I works and I can access all function but a simèple function that > print a string don't work's. > The function is like this: > int PrintTEST() > { > printf("TE

Re: Trying to extend Python with C: undefined reference to `Py_BuildValue'

2008-06-04 Thread Ivan Illarionov
On Wed, 04 Jun 2008 05:57:20 -0700, spectrumdt wrote: > Hello. > > I am trying to extend Python with some C code. I made a trivial > "Hello World" program in C that I am trying to wrap in "boilerplate" for > inclusion in a Python program. But I can't compile the C code. The C > compiler cannot

Re: printf in python

2008-06-04 Thread Ivan Illarionov
On Wed, 04 Jun 2008 14:10:51 +, Ivan Illarionov wrote: > On Mon, 02 Jun 2008 00:32:33 -0700, gianluca wrote: > >> Hy, I've a problem with may python library generated with swig from C >> code. I works and I can access all function but a simèple function >> tha

Re: can python do some kernel stuff?

2008-06-04 Thread Ivan Illarionov
On Wed, 04 Jun 2008 09:41:07 -0500, Grant Edwards wrote: >>> The answer is yes. IPC and py-pf are examples. If you don't think of >>> packet filtering as kernel coding, I can understand. But clearly the >>> Python interfaces to fork(), waitpid(), signal(), alarm() and so forth >>> are forays int

Re: Extending Python with C: Can I specify another C compiler?

2008-06-04 Thread Ivan Illarionov
On Wed, 04 Jun 2008 09:12:18 -0700, spectrumdt wrote: > Hello. > > I am trying to extend my Python program with some C code. > > This thread is sort of a follow-up to another thread of mine, linked > below. I don't know what the conventions are in this newsgroup about > creating new threads

Re: Extending Python with C: Can I specify another C compiler?

2008-06-04 Thread Ivan Illarionov
On Wed, 04 Jun 2008 09:12:18 -0700, spectrumdt wrote: > Hello. > > I am trying to extend my Python program with some C code. > > This thread is sort of a follow-up to another thread of mine, linked > below. I don't know what the conventions are in this newsgroup about > creating new threads

Re: Extending Python with C: Can I specify another C compiler?

2008-06-04 Thread Ivan Illarionov
On Wed, 04 Jun 2008 09:12:18 -0700, spectrumdt wrote: > Hello. > > I am trying to extend my Python program with some C code. > > This thread is sort of a follow-up to another thread of mine, linked > below. I don't know what the conventions are in this newsgroup about > creating new threads

Re: can python do some kernel stuff?

2008-06-04 Thread Ivan Illarionov
On Wed, 04 Jun 2008 11:24:11 -0500, Grant Edwards wrote: >> I can't understand why somebody might want to do kernel stuff in >> Python. > > we choose to put Python in kernel-space and do the other things, not > because they are easy, but because they are hard, because that goal > will

Re: Tuples part 2

2008-06-05 Thread Ivan Illarionov
On 5 июн, 01:57, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi Everyone, > > i have another question. What if i wanted to make n tuples, each with > a list of coordinates. For example : > > coords = list() > for h in xrange(1,11,1): >for i in xrange(1, 5, 1) : > for j in xrange(1, 5

Re: Tuples part 2

2008-06-05 Thread Ivan Illarionov
On 5 июн, 18:19, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Jun 5, 3:49 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > > > > > On 5 ÉÀÎ, 01:57, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > > wrote: > > > > Hi Ev

Re: Tuples part 2

2008-06-05 Thread Ivan Illarionov
On 5 июн, 18:19, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Jun 5, 3:49 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > > > > > On 5 ÉÀÎ, 01:57, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > > wrote: > > > > Hi Ev

Re: Tuples part 2

2008-06-05 Thread Ivan Illarionov
On 5 июн, 18:56, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > On 5 июн, 18:19, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > > > > On Jun 5, 3:49 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > > > > On 5 ÉÀÎ, 01:57, &quo

Re: Tuples part 2

2008-06-05 Thread Ivan Illarionov
On 5 июн, 19:38, George Sakkis <[EMAIL PROTECTED]> wrote: > On Jun 5, 11:21 am, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > > > > > On 5 июн, 18:56, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > > > > On 5 июн, 18:19, "[EMAIL PROTECTED]" &l

Re: Tuples part 2

2008-06-05 Thread Ivan Illarionov
On 5 июн, 21:22, George Sakkis <[EMAIL PROTECTED]> wrote: > On Jun 5, 11:48 am, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > > > > > On 5 июн, 19:38, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > On Jun 5, 11:21 am, Ivan Illarionov <[EMAIL

Re: Image Processing (batch)

2008-06-06 Thread Ivan Illarionov
On Thu, 05 Jun 2008 07:10:56 +, Tim Roberts wrote: > Thomas Guettler <[EMAIL PROTECTED]> wrote: >> >>I tried PIL for image batch processing. But somehow I don't like it >> - Font-Selection: You need to give the name of the font file. - >> Drawing on an image needs a different object that pas

Re: Dynamic HTML from Python Script

2008-06-11 Thread Ivan Illarionov
On Wed, 11 Jun 2008 01:05:45 +, asdf wrote: >> Well, there's a few ways you could approach it. >> >> You could create a cgi program from your script - this is probably the >> solution you're looking for. >> >> > Output from the script does come up very often. There is a new output > every 1

Re: advanced listcomprehenions?

2008-06-20 Thread Ivan Illarionov
On 20 июн, 11:31, Duncan Booth <[EMAIL PROTECTED]> wrote: > Terry Reedy <[EMAIL PROTECTED]> wrote: > >> [['Fizz', 'Buzz', 'FizzBuzz', str(i)][62/(pow(i, 4, 15) + 1)%4] for i > >> in xrange(1, 101)] > > > These make the lookup table variable, so it has to be recalculated for > > each i. > > So what?

Re: wrapping C functions in python

2008-04-10 Thread Ivan Illarionov
On Apr 10, 9:57 am, Paul Anton Letnes <[EMAIL PROTECTED]> wrote: [...] > , but as I mentioned, it seems to be a bit complicated to wrap heavy > data structures like arrays. Hello, I suggest that you might take a look at how other people solved the same problems. The great example is path.c insi

Re: get array element

2008-04-10 Thread Ivan Illarionov
On Apr 10, 9:22 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I have an array, and I would like to get the indice value. > > a = array([13,14,15,16]) > > I would like something like a.getindice(15) > > If I want 15 it would return 2 >>> a = array('i', [13,14,15,16]) >>> a.index(15) 2 -- ht

Re: Module Conflicts

2008-04-10 Thread Ivan Illarionov
On Apr 10, 2:33 am, Jose <[EMAIL PROTECTED]> wrote: > I have a module named math.py in a package with some class > definitions. I am trying to import the standard python math module > inside of math.py but It seems to be importing itself. Is there any > way around this problem without renaming my

Re: Module Conflicts

2008-04-10 Thread Ivan Illarionov
On Apr 11, 12:31 am, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > On Apr 10, 2:33 am, Jose <[EMAIL PROTECTED]> wrote: > > > I have a module named math.py in a package with some class > > definitions. I am trying to import the standard python math module > >

Re: Rounding a number to nearest even

2008-04-11 Thread Ivan Illarionov
On Apr 11, 2:14 pm, bdsatish <[EMAIL PROTECTED]> wrote: > The built-in function round( ) will always "round up", that is 1.5 is > rounded to 2.0 and 2.5 is rounded to 3.0. > > If I want to round to the nearest even, that is > > my_round(1.5) = 2# As expected > my_round(2.5) = 2# Not

Re: Rounding a number to nearest even

2008-04-11 Thread Ivan Illarionov
On Apr 11, 5:49 pm, hdante <[EMAIL PROTECTED]> wrote: > On Apr 11, 9:45 am, bdsatish <[EMAIL PROTECTED]> wrote: > > > > > On Apr 11, 5:33 pm, bdsatish <[EMAIL PROTECTED]> wrote: > > > > HI Gerard, > > > > I think you've taken it to the best possible implementation. Thanks ! > > > On Apr 11, 5:14 pm

Re: C to python conversion

2008-04-13 Thread Ivan Illarionov
itialized to NULs, because only 3 bytes > # are filled but 6 bytes are written. > os.write(_fd, buf) > buf_ret = os.read(_fd, 6) > > -- > Gabriel Genellina The easiest way is to use struct: START = 0x33 RETURN_START = 0x22 ADDR = 0x01 WRITE_CMD = 0x03 ALL_CMD = 0xFF buf = struct.pack('3b3x', START, ADDR, WRITE_CMD) os.write(_fd, buf) buf_ret = os.read(_fd, 6) And, definitely, no need for ctypes here. -- Ivan Illarionov -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for a way to include Pyhtho scripting INSIDE a python program

2008-04-13 Thread Ivan Illarionov
27;s string inside function definition, and exec it. You might want to disable words like `import`, `exec` and `eval` in user's code because it's a big security risk. -- Ivan Illarionov -- http://mail.python.org/mailman/listinfo/python-list

Re: Interesting math problem

2008-04-13 Thread Ivan Illarionov
On Mar 19, 2:17 pm, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: > On Mon, Mar 17, 2008 at 11:57 PM, Arnaud Delobelle > > > > <[EMAIL PROTECTED]> wrote: > > > def make_slope(distance, parts): > > > step = distance / float(parts) > > > intstep = int(step) > > > floatstep = step - int

Re: Looking for a way to include Pyhtho scripting INSIDE a python program

2008-04-13 Thread Ivan Illarionov
On Apr 13, 8:20 pm, Bryan Oakley <[EMAIL PROTECTED]> wrote: > Ivan Illarionov wrote: > > You don't need to envoke another interpreter. > > Python can interpret arbitrary python code with exec statement. > > Wrap user's string inside function definition, and exe

Re: Java or C++?

2008-04-15 Thread Ivan Illarionov
On 15 апр, 07:46, Brian Vanderburg II <[EMAIL PROTECTED]> wrote: [...] > C has the advantage that it does not to anything behind your back. This > is very useful especially for any form of system development or where > you must know exactly what is going on. It is still possible to do > 'object o

  1   2   >