Re: Most efficient way to "pre-grow" a list?

2009-11-07 Thread Ivan Illarionov
On Nov 6, 3:12 pm, kj wrote: > The best I can come up with is this: > > arr = [None] * 100 > > Is this the most efficient way to achieve this result? It is the most efficient SAFE way to achieve this result. In fact, there IS the more efficient way, but it's dangerous, unsafe, unpythonic and

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: 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: 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: '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: '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, 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-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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-05 Thread Ivan Illarionov
On 5 сент, 19:23, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Ivan Illarionov schrieb: > > > > > On 4 сент, 21:49, Bruno Desthuilliers > > <[EMAIL PROTECTED]> wrote: > >> Ivan Illarionov a écrit : > > >>> On 4 сент, 22:

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Ivan Illarionov
On 4 сент, 21:49, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Ivan Illarionov a écrit : > > > > > On 4 сент, 22:59, Carl Banks <[EMAIL PROTECTED]> wrote: > >> You can write code to guard against this if you want: > > >> class A: > >&g

Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Ivan Illarionov
tually catches anything. > > Carl Banks '__slots__' is better: class A(object): __slots__ = set(["x"]) def __init__(self, x): self.y = x this will do the same, only faster >>> A(1) Traceback (most recent call last): File "", line 1, in File

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: 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: 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: 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: 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 июн, 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 июн, 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 июн, 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: 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: 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 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: 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: 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 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: 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: 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: 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-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 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 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-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-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 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
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 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
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: 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: 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: 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: 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-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: 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: 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: 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: 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: 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: 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: 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: 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: 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

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

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: 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: 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: 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: 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: 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: 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-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-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: do you fail at FizzBuzz? simple prog test

2008-05-10 Thread Ivan Illarionov
On Sun, 11 May 2008 04:26:10 +, Ivan Illarionov wrote: > On Sat, 10 May 2008 18:12:37 -0700, globalrev wrote: > >> http://reddit.com/r/programming/info/18td4/comments >> >> claims people take a lot of time to write a simple program like this: >> >>

Re: do you fail at FizzBuzz? simple prog test

2008-05-10 Thread Ivan Illarionov
On Sat, 10 May 2008 18:12:37 -0700, globalrev wrote: > http://reddit.com/r/programming/info/18td4/comments > > claims people take a lot of time to write a simple program like this: > > > "Write a program that prints the numbers from 1 to 100. But for > multiples of three print "Fizz" instead of

Re: Now what!?

2008-05-10 Thread Ivan Illarionov
On 10 май, 21:22, notbob <[EMAIL PROTECTED]> wrote: > On 2008-05-10, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > > > notbob schrieb: > >> script the same way ($ ./helloworld) and it works fine. Same shebang, same > >> dir, same permission, etc. > > > I'm pretty sure you misse the correct shebang

Re: slicing lists

2008-05-07 Thread Ivan Illarionov
On Thu, 08 May 2008 01:15:43 +, Ivan Illarionov wrote: > On Wed, 07 May 2008 21:13:27 -0400, Miles wrote: > >> On Wed, May 7, 2008 at 7:46 PM, Ivan Illarionov >> <[EMAIL PROTECTED]> wrote: >> > On Wed, 07 May 2008 23:29:27 +, Yves Dorfsman wrote: &g

Re: slicing lists

2008-05-07 Thread Ivan Illarionov
On Wed, 07 May 2008 21:13:27 -0400, Miles wrote: > On Wed, May 7, 2008 at 7:46 PM, Ivan Illarionov > <[EMAIL PROTECTED]> wrote: > > On Wed, 07 May 2008 23:29:27 +, Yves Dorfsman wrote: > > > > > Is there a way to do: > > > x = [1, 2

Re: slicing lists

2008-05-07 Thread Ivan Illarionov
On Wed, 07 May 2008 23:46:33 +, Ivan Illarionov wrote: > On Wed, 07 May 2008 23:29:27 +, Yves Dorfsman wrote: > >> Is there a way to do: >> x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >> x[0,2:6] >> >> That would return: >> [0, 3, 4, 5, 6] > > IM

Re: slicing lists

2008-05-07 Thread Ivan Illarionov
On Wed, 07 May 2008 23:29:27 +, Yves Dorfsman wrote: > Is there a way to do: > x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > x[0,2:6] > > That would return: > [0, 3, 4, 5, 6] IMHO this notation is confusing. What's wrong with: [0]+x[2:6] > I am surprised this notation is not supported, it seems

Re: howto print binary number

2008-05-07 Thread Ivan Illarionov
On Wed, 07 May 2008 13:13:40 -0700, dmitrey wrote: > hi all, > could you inform how to print binary number? I.e. something like > > print '%b' % my_number > > it would be nice would it print exactly 8 binary digits (0-1, with > possible start from 0) > > Thank you in advance, D Here it is: de

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Ivan Illarionov
On Sat, 03 May 2008 17:43:57 -0700, George Sakkis wrote: > On May 3, 7:12 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: >> On Sun, 04 May 2008 00:31:01 +0200, Thomas Dybdahl Ahle wrote: >> > On Sat, 2008-05-03 at 21:37 +, Ivan Illarionov wrote: >> >>

Re: PIL JPEG mis-step

2008-05-03 Thread Ivan Illarionov
On Sat, 03 May 2008 15:25:35 -0700, darkblueB wrote: > I got the Python Imaging Library from source, built and installed, on > Ubuntu 7.10, not realizing I could run a self-test first. libjpeg is on > the machine, but was not detected.. so no JPG encoder. I got the > dev-libjpg and rebuilt PIL. Th

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Ivan Illarionov
On Sun, 04 May 2008 00:31:01 +0200, Thomas Dybdahl Ahle wrote: > On Sat, 2008-05-03 at 21:37 +0000, Ivan Illarionov wrote: >> On Sat, 03 May 2008 20:44:19 +0200, Szabolcs Horvát wrote: >> >> > Arnaud Delobelle wrote: >> >> >> >> sum() works fo

Re: PIL JPEG mis-step

2008-05-03 Thread Ivan Illarionov
On Sat, 03 May 2008 17:01:44 -0700, darkblueB wrote: > On May 3, 4:52 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: >> Try run 'python setup.py build_ext -f' to force setup.py to rebuild >> everything with JPEG. And 'sudo python setup.py install' should i

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Ivan Illarionov
On Sat, 03 May 2008 20:44:19 +0200, Szabolcs Horvát wrote: > Arnaud Delobelle wrote: >> >> sum() works for any sequence of objects with an __add__ method, not >> just floats! Your algorithm is specific to floats. > > This occurred to me also, but then I tried > > sum(['abc', 'efg'], '') Inter

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Ivan Illarionov
On Sat, 03 May 2008 18:50:34 +0200, Szabolcs Horvát wrote: > I did the following calculation: Generated a list of a million random > numbers between 0 and 1, constructed a new list by subtracting the mean > value from each number, and then calculated the mean again. > > The result should be 0, b

Re: How to use a parameter in a class

2008-05-03 Thread Ivan Illarionov
On Sat, 03 May 2008 03:05:31 -0700, Decebal wrote: > I have the following class: > # > class Dummy(): > value = 0 > def __init__(self, thisValue): > print thisValue > self.value = thisValue > value = thisValue > > def testing(self): > print 'In test

Re: Best way to store config or preferences in a multi-platform way.

2008-05-01 Thread Ivan Illarionov
On Fri, 02 May 2008 01:21:38 +0200, Torsten Bronger wrote: > Hallöchen! > > Ivan Illarionov writes: > >> [...] >> >> For me it looks more like an old-school/new-school thing than use-case >> thing. I may be wrong, but I see more and more new projects use thin

Re: Best way to store config or preferences in a multi-platform way.

2008-05-01 Thread Ivan Illarionov
On Thu, 01 May 2008 16:32:00 -0700, Carl Banks wrote: > On May 1, 4:50 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: >> On Thu, 01 May 2008 11:56:20 -0700, Carl Banks wrote: >> > On May 1, 1:30 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: >> >> On T

Re: Best way to store config or preferences in a multi-platform way.

2008-05-01 Thread Ivan Illarionov
On Thu, 01 May 2008 23:03:38 +0200, Torsten Bronger wrote: > Hallöchen! > > Ivan Illarionov writes: > >> [...] >> >> I took the example from >> http://www.kuro5hin.org/story/2004/10/29/14225/062 I haven't use my own >> example only because I

Re: Best way to store config or preferences in a multi-platform way.

2008-05-01 Thread Ivan Illarionov
On Thu, 01 May 2008 11:56:20 -0700, Carl Banks wrote: > On May 1, 1:30 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: >> On Thu, 01 May 2008 09:45:28 -0700, Carl Banks wrote: >> > On May 1, 12:11 pm, Jon Ribbens <[EMAIL PROTECTED]> wrote: >> >> On 200

Re: Best way to store config or preferences in a multi-platform way.

2008-05-01 Thread Ivan Illarionov
On Thu, 01 May 2008 14:13:08 -0500, Jon Ribbens wrote: > On 2008-05-01, Ivan Illarionov <[EMAIL PROTECTED]> wrote: >> I used XML files before for this purpose and found YAML much easier and >> better suitable for the task. >> >> Please explain why don't li

Re: Best way to store config or preferences in a multi-platform way.

2008-05-01 Thread Ivan Illarionov
On Thu, 01 May 2008 09:45:28 -0700, Carl Banks wrote: > On May 1, 12:11 pm, Jon Ribbens <[EMAIL PROTECTED]> wrote: >> On 2008-05-01, Ivan Illarionov <[EMAIL PROTECTED]> wrote: >> >> > IMO .ini-like config files are from the stone age. The modern >> >

  1   2   >