Re: how to pass C++ object to another C++ function via Python function

2008-04-21 Thread grbgooglefan
On Apr 21, 10:17 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Mon, 21 Apr 2008 10:24:15 -0300, grbgooglefan <[EMAIL PROTECTED]> escribió: > > > I am trying to pass a C++ object to Python function. This Python > > function then calls another C++ function which then uses this C++ > > objec

Re: sys.maxint in Python 3

2008-04-21 Thread Paul Rubin
[EMAIL PROTECTED] writes: > In some algorithms a sentinel value may be useful, so for Python 3.x Better to just use object() to generate sentinels. -- http://mail.python.org/mailman/listinfo/python-list

Re: Alternate indent proposal for python 3000

2008-04-21 Thread Matthew Woodcraft
Terry Reedy <[EMAIL PROTECTED]> wrote: > Off the top of my head: copy C and use {} to demarcate blocks and ';' to > end statements, so that '\n' is not needed and is just whitespace when > present. So, repeatedly scan for the next one of '{};'. That would break if those characters appear in str

Re: Any reliable obfurscator for Python 2.5

2008-04-21 Thread Matthew Woodcraft
Terry Reedy <[EMAIL PROTECTED]> wrote: > Such requests happen about once a month or so. If all the code-hiders were > to have gotten together to openly share their obfuscation ideas and code, I > suspect there would have been something pretty good by now. But in 10 > years of my watching, this

Re: Java or C++?

2008-04-21 Thread Jorgen Grahn
On Mon, 21 Apr 2008 06:14:08 -0700 (PDT), NickC <[EMAIL PROTECTED]> wrote: > On Apr 15, 1:46 pm, Brian Vanderburg II <[EMAIL PROTECTED]> > wrote: >> This will automatically call the constructors of any contained objects >> to initialize the string. The implicit assignment operator >> automatically

Re: dynamically importing a module and function

2008-04-21 Thread John Machin
[EMAIL PROTECTED] wrote: Hi I have a function data['function'], that I need to import from a file data['module'], in the directory data['cwd'] OT: Any good reason for using a dictionary instead of a class instance (data.functiom, data.module, etc)? If I do this from python interactive shel

Problems replacing \ with \\

2008-04-21 Thread [EMAIL PROTECTED]
Hi... Here's a weird problem...I'm trying to escape a bunch of data to put into a database. Here's what I have: def escape(string): """ Escape both single quotes and blackslashes >>> x = r"fun\fun" >>> escape(x) 'funfun' """ string = string.replace('\\', '')

Re: 2's complement conversion. Is this right?

2008-04-21 Thread Bob Greschke
Something is fishy. I just ran this simple-minded thing and I'm, again, getting better times for ord() than I am for unpack() on a 2.8GHz OSX iMac with 2.5.1. This is the iterate so many times you can use your wristwatch method: #! /usr/bin/env python from os import system from struct

Re: dynamically importing a module and function

2008-04-21 Thread [EMAIL PROTECTED]
On Mon, Apr 21, 2008 at 3:39 PM, John Machin <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > data['module'], in the directory data['cwd'] > OT: Any good reason for using a dictionary instead of a class instance > (data.functiom, data.module, etc)? not really, i just wanted to stick to pr

Does Python 2.5 include or not include SQLite engine?

2008-04-21 Thread python
While reading feedback to my post "Does Python 2.5.2's embedded SQLite support full text searching?" I noticed that there appears to be some confusion regarding whether Python 2.5 includes the SQLite engine. My Windows 2.5.2 binary download includes SQLite. But other posters claim otherwise, re:

Re: 2's complement conversion. Is this right?

2008-04-21 Thread Bob Greschke
On 2008-04-21 16:51:13 -0600, Bob Greschke <[EMAIL PROTECTED]> said: JUST COMPLETELY IGNORE THAT LAST ONE. What a dope. Here: #! /usr/bin/env python from os import system from struct import unpack print "unpack 1" system("date") for x in xrange(0, 1): Value = unpack(">B", "a")[0]

Re: Is massive spam coming from me on python lists?

2008-04-21 Thread Kam-Hung Soh
On Mon, 21 Apr 2008 16:01:42 +1000, Brian Vanderburg II <[EMAIL PROTECTED]> wrote: I've recently gotten more than too many spam messages and all say Sender: [EMAIL PROTECTED] I'm wondering if my mail list registration is now being used to spam myself and others. If so, sorry, but I'm no

Re: 2's complement conversion. Is this right?

2008-04-21 Thread George Sakkis
On Apr 21, 5:30 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > On 22 ÁÐÒ, 01:01, Peter Otten <[EMAIL PROTECTED]> wrote: > > > Ivan Illarionov wrote: > > > And even faster: > > > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, > > > len(s), 3 > > > if sys.byteorder == 'litt

Re: Code question

2008-04-21 Thread Mark Wooding
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote: > If anyone has time, I was wondering if you could share your thoughts > on whether this is an efficient way to do something like this, if it's > horrible and slow, etc. If your lists are fairly short then your algorithm is probably the best way to d

Re: module error in Vista -- works as administrator

2008-04-21 Thread sawilla
On Apr 21, 5:42 pm, John Machin <[EMAIL PROTECTED]> wrote: > Log on as administrator, start python in command window and do this: > > import sys > sys.path # shows where python is looking for importables > import numpy > import os.path > print os.path.abspath(numpy.__file__) # shows where it found

Re: Code question

2008-04-21 Thread George Sakkis
On Apr 21, 4:42 pm, Matimus <[EMAIL PROTECTED]> wrote: > On Apr 21, 12:05 pm, <[EMAIL PROTECTED]> wrote: > > > > > I've been trying to figure out a way to combine lists similar to how zip() > > works.  The main > > difference though is I want to work with different length lists and combine > > th

Re: module error in Vista -- works as administrator

2008-04-21 Thread John Machin
sawilla wrote: On Apr 21, 5:42 pm, John Machin <[EMAIL PROTECTED]> wrote: Log on as administrator, start python in command window and do this: import sys sys.path # shows where python is looking for importables import numpy import os.path print os.path.abspath(numpy.__file__) # shows where it f

Re: dynamically importing a module and function

2008-04-21 Thread John Machin
[EMAIL PROTECTED] wrote: On Mon, Apr 21, 2008 at 3:39 PM, John Machin <[EMAIL PROTECTED]> wrote: [EMAIL PROTECTED] wrote: data['module'], in the directory data['cwd'] OT: Any good reason for using a dictionary instead of a class instance (data.functiom, data.module, etc)? not really, i just

Re: how to pass C++ object to another C++ function via Python function

2008-04-21 Thread Gabriel Genellina
En Mon, 21 Apr 2008 19:11:31 -0300, grbgooglefan <[EMAIL PROTECTED]> escribió: On Apr 21, 10:17 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: En Mon, 21 Apr 2008 10:24:15 -0300, grbgooglefan <[EMAIL PROTECTED]> escribió: > I am trying to pass a C++ object to Python function. This Python

Re: sys.maxint in Python 3

2008-04-21 Thread castironpi
On Apr 21, 5:20 pm, Paul Rubin wrote: > [EMAIL PROTECTED] writes: > > In some algorithms a sentinel value may be useful, so for Python 3.x > > Better to just use object() to generate sentinels. Infinity is a number that compares always like. -- http://mail.python.org/mai

Re: Code question

2008-04-21 Thread Matimus
On Apr 21, 4:16 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > On Apr 21, 4:42 pm, Matimus <[EMAIL PROTECTED]> wrote: > > > > > On Apr 21, 12:05 pm, <[EMAIL PROTECTED]> wrote: > > > > I've been trying to figure out a way to combine lists similar to how > > > zip() works. The main > > > difference

Re: 2's complement conversion. Is this right?

2008-04-21 Thread Bob Greschke
On 2008-04-21 17:06:39 -0600, Bob Greschke <[EMAIL PROTECTED]> said: On 2008-04-21 16:51:13 -0600, Bob Greschke <[EMAIL PROTECTED]> said: JUST COMPLETELY IGNORE THAT LAST ONE. What a dope. Here: #! /usr/bin/env python from os import system from struct import unpack print "unpack 1" system("

Re: how to pass C++ object to another C++ function via Python function

2008-04-21 Thread Gabriel Genellina
En Mon, 21 Apr 2008 11:19:24 -0300, Diez B. Roggisch <[EMAIL PROTECTED]> escribió: Gabriel Genellina wrote: You can't pass any arbitrary C object to a Python function. In this case you can use a PyCObject, a Python box around a void* pointer. See http://docs.python.org/api/cObjects.html Ne

Segfault accessing dictionary in C Python module

2008-04-21 Thread Mitko Haralanov
I have a Python module that I have written using the C API and I am having a problem accessing a dictionary from that module. Here is what I have done: 1. In my init function I call module = Py_InitModule ("name", methods); 2. then I get the module's __dict__ structure: dict = PyMo

Re: Problems replacing \ with \\

2008-04-21 Thread MRAB
On Apr 21, 11:48 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi... > > Here's a weird problem...I'm trying to escape a bunch of data to put > into a database. > > Here's what I have: > > def escape(string): > """ > Escape both single quotes and blackslashes > >>> x = r"fun\fun"

Re: Segfault accessing dictionary in C Python module

2008-04-21 Thread sturlamolden
On Apr 22, 2:00 am, Mitko Haralanov <[EMAIL PROTECTED]> wrote: > As far as I know, I have done everything by the book yet I can't seem > to figure out where the problem is. Any help would be great? Albeit not having looked at your code in detail, I'm wiling to bet you have one of the refcounts wr

Re: Problems replacing \ with \\

2008-04-21 Thread [EMAIL PROTECTED]
HTH -- Thank you for the response. I'm not sure I understand the last sentence, although I think I get the idea. How do I create a proper doctest? Thanks On Apr 21, 9:08 pm, MRAB <[EMAIL PROTECTED]> wrote: > On Apr 21, 11:48 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > > > > Hi...

Re: Java or C++?

2008-04-21 Thread hdante
Summarizing the discussion (and giving my opinions), here's an "algorithm" to find out what language you'll leard next: 1. If you just want to learn another language, with no other essential concern, learn Ruby. 2. If you want to learn another language to design medium to large size applicatio

Re: Python 2.5 adoption

2008-04-21 Thread Patrick Mullen
On Mon, Apr 21, 2008 at 1:49 PM, Jorgen Grahn <[EMAIL PROTECTED]> wrote: > OP: keep in mind that your users do not see any gain from you using > 2.5. All they see is something that makes your software harder to > install. At some point you can dismiss them as living in the Stone Age, > but the

Re: yield expression programmized-formal interpretation. (interpretation of yield expression.)

2008-04-21 Thread Gabriel Genellina
En Mon, 21 Apr 2008 15:03:05 -0300, <[EMAIL PROTECTED]> escribió: What if I say oath= yield or other= yield ? Does yield evaluate without parenthes? (Eth.) You can't use yield except in a generator function. From and the grammar definit

Lists: why is this behavior different for index and slice assignments?

2008-04-21 Thread John Salerno
Hey all. I've decided I let my Python skills (minor though they were) slip away so I started reading the new edition of Learning Python to brush up. I just read about lists again and I'm wondering if someone could explain what's going on under the hood that makes index and slice assignments beh

Re: py3k concerns. An example

2008-04-21 Thread Gabriel Genellina
En Mon, 21 Apr 2008 16:42:41 -0300, Ross Ridge <[EMAIL PROTECTED]> escribió: Ideally, I can implement some form of cross-compatible code so that I need maintain only a single code base, and I have managed to do so on a number of fronts (with the help of Robert A. Clark): Perhaps you can mana

Re: Lists: why is this behavior different for index and slice assignments?

2008-04-21 Thread Michael Torrie
John Salerno wrote: > So the question is, when you assign an empty list to an index, why does > it insert an empty list, but when you assign an empty list to a slice, > it simply deletes the slice? I would say this is consistent behavior because a list slice is also a list itself. Whereas a lis

Re: Lists: why is this behavior different for index and slice assignments?

2008-04-21 Thread Steve Holden
John Salerno wrote: Hey all. I've decided I let my Python skills (minor though they were) slip away so I started reading the new edition of Learning Python to brush up. I just read about lists again and I'm wondering if someone could explain what's going on under the hood that makes index and s

Re: Problems replacing \ with \\

2008-04-21 Thread Michael Torrie
[EMAIL PROTECTED] wrote: > Hi... > > Here's a weird problem...I'm trying to escape a bunch of data to put > into a database. Is it possible to use the database API and prepared statements to avoid having to go through this exercise? Also, most database APIs work natively in unicode, so creating

Re: Java or C++?

2008-04-21 Thread Dan Bishop
On Apr 21, 5:26 pm, Jorgen Grahn <[EMAIL PROTECTED]> wrote: > On Mon, 21 Apr 2008 06:14:08 -0700 (PDT), NickC <[EMAIL PROTECTED]> wrote: > > On Apr 15, 1:46 pm, Brian Vanderburg II <[EMAIL PROTECTED]> > > wrote: > >> This will automatically call the constructors of any contained objects > >> to ini

Re: Problems replacing \ with \\

2008-04-21 Thread Gabriel Genellina
(top posting corrected) En Mon, 21 Apr 2008 21:12:44 -0300, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribió: > def escape(string): > """ > Escape both single quotes and blackslashes > >>> x = r"fun\fun" > >>> escape(x) > 'funfun' > """ > string = string.replace

Re: Alternate indent proposal for python 3000

2008-04-21 Thread Dan Bishop
On Apr 21, 4:01 am, Paul Boddie <[EMAIL PROTECTED]> wrote: > On 21 Apr, 00:54, Dan Bishop <[EMAIL PROTECTED]> wrote: > > > > > We wouldn't even need that. Just a new source encoding. Then we > > could write: > > > # -*- coding: end-block -*- > > [...] > > Someone at EuroPython 2007 did a lightnin

Re: why objects of old style classes are instances of 'object'

2008-04-21 Thread AlFire
Diez B. Roggisch wrote: But not everything is a newstyle-class: class Foo: pass ... isinstance(Foo, object) True isinstance(Foo, type) False class Bar(object): pass ... isinstance(Bar, type) True thx for explanation. but more I look at it less and less

Re: 2's complement conversion. Is this right?

2008-04-21 Thread Ivan Illarionov
On Mon, 21 Apr 2008 16:10:05 -0700, George Sakkis wrote: > On Apr 21, 5:30 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > >> On 22 ÁÐÒ, 01:01, Peter Otten <[EMAIL PROTECTED]> wrote: >> >> > Ivan Illarionov wrote: >> > > And even faster: >> > > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for

Re: 2's complement conversion. Is this right?

2008-04-21 Thread Ivan Illarionov
On Mon, 21 Apr 2008 16:10:05 -0700, George Sakkis wrote: > On Apr 21, 5:30 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > >> On 22 ÁÐÒ, 01:01, Peter Otten <[EMAIL PROTECTED]> wrote: >> >> > Ivan Illarionov wrote: >> > > And even faster: >> > > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for

Re: py3k concerns. An example

2008-04-21 Thread Martin v. Löwis
> In py3k string%dictionary is going away. Why do you say that? It's not going away in Python 3.0. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: why objects of old style classes are instances of 'object'

2008-04-21 Thread Gabriel Genellina
En Tue, 22 Apr 2008 00:49:27 -0300, AlFire <[EMAIL PROTECTED]> escribió: Diez B. Roggisch wrote: But not everything is a newstyle-class: class Foo: pass ... isinstance(Foo, object) True isinstance(Foo, type) False class Bar(object): pass ... isinstance(Bar, type) True th

Re: Does Python 2.5 include or not include SQLite engine?

2008-04-21 Thread Banibrata Dutta
Doesn't this depend on the source / distro ? My Python is from the ActivePython distro, while I am not sure (since I've just about started playing with it), I haven't seen SQLite included ... possible that I missed it. On 4/22/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > While reading feed

Re: py3k concerns. An example

2008-04-21 Thread Hrvoje Niksic
"Martin v. Löwis" <[EMAIL PROTECTED]> writes: >> In py3k string%dictionary is going away. > > Why do you say that? It's not going away in Python 3.0. I also got the impression that it was going away. PEP 3101's abstract says: This PEP proposes a new system for built-in string formatting

<    1   2