Re: How do I call super() in c extention ?

2012-01-26 Thread Stefan Behnel
umedoblock, 27.01.2012 03:03: > I'd like to call super() in c extension. > I'd like to rewrite class Baa as c extension. Have you considered using Cython for this? It will allow you to do exactly that with only minor changes to your Python code (if any). And it's quite likely that the C code that

Re: constraint based killer sudoku solver performance improvements

2012-01-26 Thread Blockheads Oi Oi
On 27/01/2012 06:57, Frank Millman wrote: "Blockheads Oi Oi" wrote: I have a working program based on [1] that sets up all different constraints for each row, column and box and then sets exact sum constraints for each cage. It'll run in around 0.2 secs for a simple problem, but a tough one

Re: constraint based killer sudoku solver performance improvements

2012-01-26 Thread Frank Millman
"Blockheads Oi Oi" wrote: >I have a working program based on [1] that sets up all different >constraints for each row, column and box and then sets exact sum >constraints for each cage. It'll run in around 0.2 secs for a simple >problem, but a tough one takes 2 hours 45 minutes. I did some

Re: Constraints -//- first release -//- Flexible abstract class based validation for attributes, functions and code blocks

2012-01-26 Thread Nathan Rice
> May I suggest a look at languages such as ATS and Epigram? They use > types that constrain values specifically to prove things about your > program. Haskell is a step, but as far as proving goes, it's less > powerful than it could be. ATS allows you to, at compile-time, declare > that isinstance(

Re: Where to put data

2012-01-26 Thread Michael Torrie
On 01/26/2012 09:30 AM, bvdp wrote: > Yes. I agree and it's nice to have a confirmation. So far I've been > putting all my program into /usr/local/share/MYPROGRAM and then > simply inserting an entry into sys.path. > > Then, for other systems, I check a few common locations until I find > the inst

Re: write 中文 into c:\t1

2012-01-26 Thread Dave Angel
On 01/26/2012 09:46 PM, contro opinion wrote: s='\xd6\xd0\xce\xc4' print s 中文 s1=s.decode('gbk').encode('utf-8') print s1 涓 file=open('c:\\t1','w') file.write(s1) file.close() > when i open c:\t1,i get 中文 in it, > how can i write 涓 into c:\t1??

Re: write 中文 into c:\t1

2012-01-26 Thread MRAB
On 27/01/2012 02:46, contro opinion wrote: |>>> s='\xd6\xd0\xce\xc4' print s 中文 s1=s.decode('gbk').encode('utf-8') print s1 涓枃 file=open('c:\\t1','w') file.write(s1) file.close() | when i open c:\t1,i get 中文 in it, how can i write 涓枃 into c:\t1?? >>> file.write(p

write 涓���� into c:\t1

2012-01-26 Thread contro opinion
>>> s='\xd6\xd0\xce\xc4' >>> print s >>> 中文 >>> s1=s.decode('gbk').encode('utf-8') >>> print s1 >>> 涓 >>> file=open('c:\\t1','w') >>> file.write(s1) >>> file.close() when i open c:\t1,i get 中文 in it, how can i write 涓 into c:\t1?? >>> file.write(print s1) File "", line 1 file.write

How do I call super() in c extention ?

2012-01-26 Thread umedoblock
Hi, nice to meet you, everyone. I'm umedoblock. I'd like to call super() in c extension. I'd like to rewrite class Baa as c extension. Please see below code. Now, I can make super object. But I cannot understand how to use super_init(), super_descr_get() and super_getattro(). Please please help

Re: Weird newbie question

2012-01-26 Thread Matty Sarro
The issue was a version mismatch. When installing python on windows, it installs a shortcut so when you right click, you can edit things in IDLE. I had installed python 3 after installing 2.7, so it apparently changed the extension. As for not showing tracebacks, I couldn't. When I ran the program

Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-26 Thread alex23
Steven D'Aprano wrote: > The Oxford Dictionary lists the first definition of "pretty" as > >     Orig. cunning, crafty. Later (of a person) clever, skillful; >    (of a thing) cleverly made or done, ingenious, artful. > > and states that it is derived from Old English praettig, "capricious, > over

Re: What happened tp scipy.stsci?

2012-01-26 Thread Eelco
On Jan 27, 12:04 am, Wanderer wrote: > On Jan 26, 2:56 pm, Wanderer wrote: > > > On Jan 25, 1:12 pm, Wanderer wrote: > > > > I found it it is in the stsci package. > > > > On Jan 24, 11:36 am, Eelco wrote: > > > > > Either way, if I understand correctly, what you are trying to do could > > > >

Re: Constraints -//- first release -//- Flexible abstract class based validation for attributes, functions and code blocks

2012-01-26 Thread Devin Jeanpierre
On Thu, Jan 26, 2012 at 3:24 PM, Nathan Rice wrote: > One of the nice things about Haskell is that the language is designed > in a way that is conducive to > proving things about your code.  A side benefit of being able to prove > things about your code is that > in some cases you will be able to

Re: What happened tp scipy.stsci?

2012-01-26 Thread Wanderer
On Jan 26, 2:56 pm, Wanderer wrote: > On Jan 25, 1:12 pm, Wanderer wrote: > > > I found it it is in the stsci package. > > > On Jan 24, 11:36 am, Eelco wrote: > > > > Either way, if I understand correctly, what you are trying to do could > > > be done with numpy.median(imagestack, axis=stackaxis

Re: Weird newbie question

2012-01-26 Thread Rick Johnson
On Jan 26, 4:05 pm, Matty Sarro wrote: > Here's my code: > > from sys import argv > script,filename=argv > txt=open(filename) > print "Here is your file %r:" % filename > print txt.read() > print "I'll also ask you to type it again:" > file_again=raw_input("> ") > txt_again=open(file_again) > pri

Re: Weird newbie question

2012-01-26 Thread John Gordon
In Matty Sarro writes: > Hey everyone. I'm running into a funky error as I work through "Learn > Python the Hard Way." What's weird is both idle and the python > interpreter in idle spit out an error about syntax, but when I run the > same script from the command line it works just fine, with n

Re: Weird newbie question

2012-01-26 Thread Ethan Furman
Matty Sarro wrote: from sys import argv script,filename=argv txt=open(filename) print "Here is your file %r:" % filename print txt.read() print "I'll also ask you to type it again:" file_again=raw_input("> ") txt_again=open(file_again) print txt_again.read() IDLE is saying that my error is on li

Re: Weird newbie question

2012-01-26 Thread Steven D'Aprano
On Thu, 26 Jan 2012 17:05:57 -0500, Matty Sarro wrote: > Hey everyone. I'm running into a funky error as I work through "Learn > Python the Hard Way." What's weird is both idle and the python > interpreter in idle spit out an error about syntax, but when I run the > same script from the command li

Re: Weird newbie question

2012-01-26 Thread Andrea Crotti
On 01/26/2012 10:05 PM, Matty Sarro wrote: Hey everyone. I'm running into a funky error as I work through "Learn Python the Hard Way." What's weird is both idle and the python interpreter in idle spit out an error about syntax, but when I run the same script from the command line it works just fi

Weird newbie question

2012-01-26 Thread Matty Sarro
Hey everyone. I'm running into a funky error as I work through "Learn Python the Hard Way." What's weird is both idle and the python interpreter in idle spit out an error about syntax, but when I run the same script from the command line it works just fine, with no issue. I'm not sure if its an iss

profiling the evolution

2012-01-26 Thread Andrea Crotti
I am doing some analysis of profiling results and I use gprof2dot to generate nice graphs. Now I was thinking, wouldn't it be great to have a way to get a nice report that summarizes the evolution of my code. For example given two versions : version 1: func1: 10 seconds func2: 20 seconds ver

Re: Constraints -//- first release -//- Flexible abstract class based validation for attributes, functions and code blocks

2012-01-26 Thread Nathan Rice
On Thu, Jan 26, 2012 at 2:51 PM, Devin Jeanpierre wrote: > Ooh, runtime turing-complete dependent-types. :) > > I'm not sure if you're aware of the literature on this sort of thing. > It's nice reading. A library such as this that's designed for it could > be used for static checks as well. Actua

Re: What happened tp scipy.stsci?

2012-01-26 Thread Wanderer
On Jan 25, 1:12 pm, Wanderer wrote: > I found it it is in the stsci package. > > On Jan 24, 11:36 am, Eelco wrote: > > > Either way, if I understand correctly, what you are trying to do could > > be done with numpy.median(imagestack, axis=stackaxis), no? > > Yes, I guess so. I didn't realize nump

Re: Constraints -//- first release -//- Flexible abstract class based validation for attributes, functions and code blocks

2012-01-26 Thread Devin Jeanpierre
Ooh, runtime turing-complete dependent-types. :) I'm not sure if you're aware of the literature on this sort of thing. It's nice reading. A library such as this that's designed for it could be used for static checks as well. Probably deserves a better name than "constraintslib", that makes one th

Constraints -//- first release -//- Flexible abstract class based validation for attributes, functions and code blocks

2012-01-26 Thread Nathan Rice
PyPi name: constraintslib (you'll be dissapointed if you get constraints by accident) Docs: http://packages.python.org/constraintslib/ Github: https://github.com/nathan-rice/Constraints >From the docs: Constraints - Sleek contract-style validation tools =

Re: Where to put data

2012-01-26 Thread Martin P. Hellwig
On 25/01/2012 17:26, bvdp wrote: Well once you think about distributing, here is the guide line I use: - If it is meant as a library that can be 'imported' in python: > site-packages is the place to be, some linux distros are rather creative with them so be careful. - If it is a 'stand-alon

Re: First python project : Tuner

2012-01-26 Thread Jérôme
Fri, 20 Jan 2012 12:13:30 +0200 Anssi Saari a écrit: > Jérôme writes: > > > - I tried to clarify the dependencies of my program by adding > > "PyGObject (python-gi)." > > I believe PyGObject is the name, but python-gi being the name of the > > debian package (and possibly other distros' pac

constraint based killer sudoku solver performance improvements

2012-01-26 Thread Blockheads Oi Oi
I have a working program based on [1] that sets up all different constraints for each row, column and box and then sets exact sum constraints for each cage. It'll run in around 0.2 secs for a simple problem, but a tough one takes 2 hours 45 minutes. I did some research into improving the perf

Re: Where to put data

2012-01-26 Thread Dan Stromberg
I think that /usr/*/python-whatever/site-packages and related directories are very much overused in the python world, and tend to cause problems eventually - EG when you need to install two versions of a program on the same machine, same interpreter. I prefer to provide a configure script that acc

Re: Where to put data

2012-01-26 Thread bvdp
On Wednesday, January 25, 2012 8:30:54 PM UTC-7, Michael Torrie wrote: > Unless you are writing a python library that will be used by others, I > don't think that where you put your files has anything to do with being > "pythonic" or not. Just do what works for your OS. Yes. I agree and it's nic

Re: Distributing methods of a class across multiple files

2012-01-26 Thread Chris Angelico
On Fri, Jan 27, 2012 at 1:11 AM, Roy Smith wrote: > So, I'd say the driving principle should be that a function should do > one thing.  Every function should have an elevator talk.  You should be > able to get on an elevator with a function and when you ask it, "So, > what do you do?", it should b

Re: import fails in non-interactive interpreter

2012-01-26 Thread Brian Brinegar
On Thu, Jan 26, 2012 at 8:49 AM, Jean-Michel Pichavant wrote: > Brian Brinegar wrote: >> >> JM, >> >> Thanks for the response, you're correct '' is pre-pended to the path >> in interactive mode. I've tried adding . to my PYTHONPATH and it >> doesn't solve the problem. >> >> When imported from inte

Re: Algorithms in Python

2012-01-26 Thread Chetan Harjani
On Thu, Jan 26, 2012 at 2:22 AM, Martin Schöön wrote: > On 2012-01-25, Chetan Harjani wrote: >> Thanks Alec for the link. U know I wanted to read this book by Simon >> Singh -> The Code Book, I hear its good. >> > It indeed is. I only remember one error, an error every Scandinavian > would have s

Re: Distributing methods of a class across multiple files

2012-01-26 Thread Roy Smith
In article , Dennis Lee Bieber wrote: > The old convention I'd learned was to keep functions down to a > (printer) page (classical 6 lines per inch, 11" high, tractor feed -- so > about 60 lines per function -- possibly extend to a second page if > really needed. The generalization of tha

Re: import fails in non-interactive interpreter

2012-01-26 Thread Jean-Michel Pichavant
Brian Brinegar wrote: JM, Thanks for the response, you're correct '' is pre-pended to the path in interactive mode. I've tried adding . to my PYTHONPATH and it doesn't solve the problem. When imported from interactive python the paste.deploy module is located at: import paste.deploy paste.

Re: how to get my character?

2012-01-26 Thread contro opinion
there is no answer, i can't get "你好" from '\xc4\xe3\xba\xc3' 2012/1/26 Lutz Horn > Hi, > > On Thu, 26 Jan 2012 20:52:48 +0800, contro opinion wrote: > >> how can i get "你好" from 'xc4xe3xbaxc3' ? >> > > Please share any results you get from http://stackoverflow.com/** > questions/9018303/ho

Re: how to get my character?

2012-01-26 Thread Dave Angel
On 01/26/2012 07:52 AM, contro opinion wrote: > my system:xp+python27 the codec, xp gbk;python 27 ascii > > a = '你好' > a > '\xc4\xe3\xba\xc3' > print a > 你好 > '\xc4\xe3\xba\xc3'.decode('gbk') > u'\u4f60\u597d' > '\xc4\xe3\xba\xc3'.encode('gbk') > Traceback (most recent call last): File "", line 1,

Re: problems with tkinter updates

2012-01-26 Thread Peter Otten
woooee wrote: [Peter Otten] >> line = next(infile, None) >> if line is not None: > if line is not None: probably does not work the way you expect. It does what I expect. > You might try > if line.strip(): > Take a look at this quick example > > test_lines = ["Number 1\n", "\n", ""] >

Re: how to get my character?

2012-01-26 Thread Lutz Horn
Hi, On Thu, 26 Jan 2012 20:52:48 +0800, contro opinion wrote: how can i get "你好" from 'xc4xe3xbaxc3' ? Please share any results you get from http://stackoverflow.com/questions/9018303/how-to-get-my-character with python-list. Lutz -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get my character?

2012-01-26 Thread Peter Otten
contro opinion wrote: > how can i get "你好" from '\xc4\xe3\xba\xc3' ? >>> print '\xc4\xe3\xba\xc3'.decode("gbk") 你好 General rule: use the decode() method to convert from bytestring to unicode and encode() to convert from unicode to bytestring. bytestring.encode(x) will implicitly try bytestrin

how to get my character?

2012-01-26 Thread contro opinion
my system:xp+python27 the codec, xp gbk;python 27 ascii a = '你好' a '\xc4\xe3\xba\xc3' print a 你好 '\xc4\xe3\xba\xc3'.decode('gbk') u'\u4f60\u597d' '\xc4\xe3\xba\xc3'.encode('gbk') Traceback (most recent call last): File "", line 1, in UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in pos

Re: import fails in non-interactive interpreter

2012-01-26 Thread Brian Brinegar
JM, Thanks for the response, you're correct '' is pre-pended to the path in interactive mode. I've tried adding . to my PYTHONPATH and it doesn't solve the problem. When imported from interactive python the paste.deploy module is located at: >>> import paste.deploy >>> paste.deploy.__path__ ['/h

running in a virtualenv

2012-01-26 Thread Andrea Crotti
I have a python script which has to run some other code and to separate the different projects I'm using virtualenv. What my this script does is: - check if the virtualenv exists already, otherwise create it with virtualenv.create_environment(venv_path, site_packages=True,

Re: import fails in non-interactive interpreter

2012-01-26 Thread Jean-Michel Pichavant
Brian wrote: I've been banging my head against this for the past hour, and I'm hoping someone here can set me straight. [Snip] but, using the same same python, I'm able to import the module from the interactive interpreter. The PATH and PYTHONPATH environment variables are identical in both

Re: Distributing methods of a class across multiple files

2012-01-26 Thread Chris Angelico
On Thu, Jan 26, 2012 at 2:19 AM, lh wrote: > Third, length. Well 5000 lines eh... I'm nowhere near that guess I can > stick with one file. Of all the source files I have at work, the largest is about that, 5K lines. It gets a little annoying at times (rapid deployment requires GCC to do its magic