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

2009-11-07 Thread Ivan Illarionov
On Nov 6, 3:12 pm, kj no.em...@please.post 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,

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 bjou...@gmail.com 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

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, but it's not

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 kylo...@gmail.com 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

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 kylo...@gmail.com 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

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 ivan.illario...@gmail.com wrote: On Jan 14, 8:00 pm, Ben Sizer kylo...@gmail.com 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

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

2009-01-13 Thread Ivan Illarionov
Ben Sizer kylo...@gmail.com 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,

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 fetchin...@googlemail.com 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

Re: Custom C Exception Subclasses

2008-12-24 Thread Ivan Illarionov
On Dec 24, 6:42 pm, Ross rlig...@gmail.com 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

Re: Custom C Exception Subclasses

2008-12-24 Thread Ivan Illarionov
On Dec 24, 10:43 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Wed, 24 Dec 2008 15:48:34 -0200, Gabriel Genellina   gagsl-...@yahoo.com.ar escribió: En Wed, 24 Dec 2008 15:00:36 -0200, Ivan Illarionov   ivan.illario...@gmail.com escribió: When you raise an exception in C++ you

Re: PIL - font kerning

2008-12-23 Thread Ivan Illarionov
On 23 дек, 16:44, carsn carsten.kr...@gmail.com 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

Re: PIL - font kerning

2008-12-23 Thread Ivan Illarionov
On Dec 23, 11:22 pm, Ivan Illarionov ivan.illario...@gmail.com wrote: On 23 дек, 16:44, carsn carsten.kr...@gmail.com 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

Re: Beep

2008-12-23 Thread Ivan Illarionov
On Dec 22, 3:16 am, Jeffrey Barish jeff_bar...@earthlink.net 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

Re: C API and memory allocation

2008-12-18 Thread Ivan Illarionov
On 18 дек, 03:51, Aaron Brady castiro...@gmail.com 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

Re: C API and memory allocation

2008-12-18 Thread Ivan Illarionov
On 18 дек, 14:09, Ivan Illarionov ivan.illario...@gmail.com 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: Memory leak when using a C++ module for Python

2008-12-16 Thread Ivan Illarionov
On Dec 11, 8:35 pm, Jaume Bonet jaume.bo...@gmail.com wrote: snip         //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)         vectorstring

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

2008-12-16 Thread Ivan Illarionov
On Dec 16, 11:25 pm, Joe Strout j...@strout.net 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

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 following

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 it in C. I am able to raise exceptions successfully

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: snip def getAge():     while True:         try:             age = int(input('Please enter your age: '))             return age         except ValueError:  

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:59, Carl Banks [EMAIL PROTECTED] wrote: You can write code to guard against this if you want

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

2008-09-04 Thread Ivan Illarionov
__init__(self, x): self.y = x this will do the same, only faster A(1) Traceback (most recent call last): File stdin, line 1, in module File stdin, line 4, in __init__ AttributeError: 'A' object has no attribute 'y' Ivan Illarionov -- http://mail.python.org/mailman/listinfo/python

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: legal = set([x]) def __setattr__(self,attr,val): if attr

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? Mark Wooding was

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 10 secs and

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

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, 1) :

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 Everyone, i have another question. What if i wanted to make n tuples, each with a list

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 Everyone, i have another question. What if i wanted to make n tuples, each with a list

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, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi Everyone, i have another question

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] [EMAIL PROTECTED] wrote: On Jun 5, 3:49 pm, Ivan Illarionov [EMAIL

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 PROTECTED] wrote: On 5 июн, 18:56, Ivan Illarionov [EMAIL PROTECTED

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

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(TEST );

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

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 that print a string don't work's

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 into the once

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

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

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

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 serve

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 said before - good programmers can write good code in any language

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 can. But it may be harder to do for them in one language

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 - good programmers can write good code in any language. Yes

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, As I've said before - good programmers can write good code in any

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: Greetings, Ivan Illarionov. In reply to Your message dated Monday, May 26

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

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 property

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 property

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 wordwank or whatever.

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

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

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/week in

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 for them in one language and easier in another. Ivan

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

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

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 interpreted

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

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: [ [x,2*x] for x

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 bruno. [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 usually said that

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 PROTECTED] escribió: After re-reading Python

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: 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 very Bad Thing. I can't see any use-case of them

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

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 i = 0

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 etremely

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: usage of python

2008-05-14 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 the

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

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 by

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

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

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 little non-python thing,

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

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

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

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 the

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: Write a program that prints the numbers from 1

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: def bin(x,

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: 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] IMHO this notation is confusing. What's wrong with: [0]+x[2:6

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, 3, 4, 5, 6, 7, 8, 9, 10] x[0,2:6] That would return

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: Is there a way to do: x = [1, 2, 3, 4

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: %d' %

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

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'], '') Interesting, I

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 install PIL with JPEG support. yes

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 +, Ivan Illarionov wrote: 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

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

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: On Sat, 03 May 2008 20:44:19 +0200, Szabolcs Horvá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 08:30:03 -0500, Nick Craig-Wood wrote: Lance Gamet [EMAIL PROTECTED] wrote: This project will store most of its actual data in a shared-database, but I have a small amount of user specific data that I need to be stored like configuration or preferences for example, the

Re: Signals/Slots support in Python

2008-05-01 Thread Ivan Illarionov
On Thu, 01 May 2008 08:44:27 -0600, Scott SA wrote: Did you review this? http://pydispatcher.sourceforge.net/ from what I understand is originally based upon this: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/87056 and subsequently integrated into this:

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:11:29 -0500, Jon Ribbens wrote: On 2008-05-01, Ivan Illarionov [EMAIL PROTECTED] wrote: IMO .ini-like config files are from the stone age. The modern approach is to use YAML (http://www.yaml.org). You mean YAML isn't a joke!? It's so ludicrously overcomplicated

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 approach is to use YAML (http://www.yaml.org). You mean

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 like YANL so much? Because even the examples

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 2008-05-01, Ivan Illarionov [EMAIL PROTECTED] wrote: IMO

  1   2   >