Executing .pyc using python c api

2011-11-29 Thread Mrinalini Kulkarni
Hi I need to run .pyc files using python c api. if i do PyImport_Import it executes the script. However, i need to pass a set of variables and their values which will be accessed from within the script. How can this be done. thanks, -- http://mail.python.org/mailman/listinfo/python-list

Re: Using the Python Interpreter as a Reference

2011-11-29 Thread Steven D'Aprano
On Tue, 29 Nov 2011 12:49:49 +1100, Chris Angelico wrote: > On Tue, Nov 29, 2011 at 11:54 AM, DevPlayer wrote: >> To me, I would think the interpreter finding the coder's intended >> indent wouldn't be that hard. And just make the need for consistant >> spaces or tabs irrevelent simply by reforma

Re: Using the Python Interpreter as a Reference

2011-11-29 Thread Steven D'Aprano
On Tue, 29 Nov 2011 13:57:32 +1100, Chris Angelico wrote: > I'm inclined toward an alternative: explicit recursion. Either a > different syntax, or a special-case on the use of the function's own > name, but whichever syntax you use, it compiles in a "recurse" opcode. > That way, if name bindings

Re: Executing .pyc using python c api

2011-11-29 Thread Stefan Behnel
Mrinalini Kulkarni, 29.11.2011 08:34: I need to run .pyc files using python c api. if i do PyImport_Import it executes the script. However, i need to pass a set of variables and their values which will be accessed from within the script. How can this be done. Assuming you have the source as wel

Re: Pragmatics of the standard is() function

2011-11-29 Thread Steven D'Aprano
On Mon, 28 Nov 2011 11:22:09 -0800, Den wrote: > With respect, I disagree with advice that the use of a language > construct should be rare. All constructs should be used > *appropriately*. And if those appropriate conditions are rare, then the use of the appropriate construct should also be ra

Re: Using the Python Interpreter as a Reference

2011-11-29 Thread Dave Angel
On 11/29/2011 03:12 AM, Steven D'Aprano wrote: On Tue, 29 Nov 2011 13:57:32 +1100, Chris Angelico wrote: I'm inclined toward an alternative: explicit recursion. Either a different syntax, or a special-case on the use of the function's own name, but whichever syntax you use, it compiles in a "re

Re: Executing .pyc using python c api

2011-11-29 Thread Ulrich Eckhardt
Am 29.11.2011 08:34, schrieb Mrinalini Kulkarni: I need to run .pyc files using python c api. if i do PyImport_Import it executes the script. However, i need to pass a set of variables and their values which will be accessed from within the script. How can this be done. I don't think what you w

Re: python 2.5 and ast

2011-11-29 Thread Andrea Crotti
On 11/29/2011 03:55 AM, Dave Angel wrote: But don't forget to tag it as version specific, so it gets removed when the later version of the library is available. There are various ways of doing that, but the easiest is probably to put a test in the acceptance suite that fails if this code is

Re: python 2.5 and ast

2011-11-29 Thread Arnaud Delobelle
On 29 November 2011 09:51, Andrea Crotti wrote: > from sys import version_info > > if version_info[1] == 5: >    from psi.devsonly.ast import parse, NodeVisitor > else: >    from ast import parse, NodeVisitor Why don't you just: try: from ast import parse, NodeVisitor except ImportError:

Can I submit an issue with Python 2.5.6?

2011-11-29 Thread Toshiyuki Ogura
Hi. I found a problem with Python 2.5.6. test_commands fails when 'make test'. bugs.python.org doesn't seem to have an option for Python 2.5 in "Versions:" drop-down menu when creating an issue. The problem seems to be the same as #11946. http://bugs.python.org/issue11946 I also made a patch for

Re: python 2.5 and ast

2011-11-29 Thread Steven D'Aprano
On Tue, 29 Nov 2011 09:51:24 +, Andrea Crotti wrote: > On 11/29/2011 03:55 AM, Dave Angel wrote: >> >> But don't forget to tag it as version specific, so it gets removed when >> the later version of the library is available. There are various ways >> of doing that, but the easiest is probably

Re: suppressing bad characters in output PCDATA (converting JSON to XML)

2011-11-29 Thread Adam Funk
On 2011-11-28, Stefan Behnel wrote: > Adam Funk, 25.11.2011 14:50: >> I'm converting JSON data to XML using the standard library's json and >> xml.dom.minidom modules. I get the input this way: >> >> input_source = codecs.open(input_file, 'rb', encoding='UTF-8', >> errors='replace') > > It doesn

Re: suppressing bad characters in output PCDATA (converting JSON to XML)

2011-11-29 Thread Adam Funk
On 2011-11-28, Steven D'Aprano wrote: > On Fri, 25 Nov 2011 13:50:01 +, Adam Funk wrote: > >> I'm converting JSON data to XML using the standard library's json and >> xml.dom.minidom modules. I get the input this way: >> >> input_source = codecs.open(input_file, 'rb', encoding='UTF-8', >> er

Re: python 2.5 and ast

2011-11-29 Thread Andrea Crotti
On 11/29/2011 11:32 AM, Steven D'Aprano wrote: I prefer to check against sys.version. import sys if sys.version<= '2.5': from psi.devsonly.ast import parse, NodeVisitor else: from ast import parse, NodeVisitor Or even: try: from ast import parse, NodeVisitor except ImportErr

Re: Can I submit an issue with Python 2.5.6?

2011-11-29 Thread Matt Joiner
Note the re.VERBOSE flag allows this whitespace treatment of the pattern. 2011/11/29 Toshiyuki Ogura : > Hi. > > I found a problem with Python 2.5.6. > test_commands fails when 'make test'. > bugs.python.org doesn't seem to have an option for Python 2.5 in "Versions:" > drop-down menu when creatin

Re: Executing .pyc using python c api

2011-11-29 Thread 88888 Dihedral
On Tuesday, November 29, 2011 5:02:31 PM UTC+8, Ulrich Eckhardt wrote: > Am 29.11.2011 08:34, schrieb Mrinalini Kulkarni: > > I need to run .pyc files using python c api. if i do PyImport_Import it > > executes the script. However, i need to pass a set of variables and > > their values which will b

Re: suppressing bad characters in output PCDATA (converting JSON to XML)

2011-11-29 Thread Stefan Behnel
Adam Funk, 29.11.2011 13:57: On 2011-11-28, Stefan Behnel wrote: Adam Funk, 25.11.2011 14:50: Then I recurse through the contents of big_json to build an instance of xml.dom.minidom.Document (the recursion includes some code to rewrite dict keys as valid element names if necessary) If the nam

RE: Can I submit an issue with Python 2.5.6?

2011-11-29 Thread Toshiyuki Ogura
I mistakenly posted the previous message in html format, and some rubbish text '&nbs p;' was unexpectedly inserted in the patch. I'll post the content of the patch again. Sorry for the inconvenience. --- Python-2.5.6/Lib/test/test_commands.py.orig    2006-06-29 04:10:08.0 + +++ Pyt

Amateur question on class definitions...

2011-11-29 Thread J. Marc Edwards
So I am defining my Python classes for a Django data model. I have a the following class hierarchy and would value some expert input on how to best implement this. I have many instances of a particular class which I call a "workflow", e.g. wf_1, wf_2, wf_3, etc. These class instances of workflows

Re: Amateur question on class definitions...

2011-11-29 Thread Chris Angelico
On Wed, Nov 30, 2011 at 2:21 AM, J. Marc Edwards wrote: >     ...a list of "a_workflows", i.e. a composite workflow, should I use this > syntax? >     set_of_workflows = list(a_workflow) > This would be usual: set_of_workflows = [a_workflow] Using the list() constructor directly is for when you

Re: Amateur question on class definitions...

2011-11-29 Thread Ian Kelly
On Tue, Nov 29, 2011 at 8:21 AM, J. Marc Edwards wrote: > So I am defining my Python classes for a Django data model.  I have a the > following class hierarchy and would value some expert input on how to best > implement this. > > I have many instances of a particular class which I call a "workflo

Re: Pragmatics of the standard is() function

2011-11-29 Thread Den
On Nov 29, 12:41 am, Steven D'Aprano wrote: > On Mon, 28 Nov 2011 11:22:09 -0800, Den wrote: > > With respect, I disagree with advice that the use of a language > > construct should be rare.  All constructs should be used > > *appropriately*. > > And if those appropriate conditions are rare, then

Re: Can I submit an issue with Python 2.5.6?

2011-11-29 Thread Jerry Hill
2011/11/29 Toshiyuki Ogura > I found a problem with Python 2.5.6. > ... > Can I submit the issue at bugs.python.org? > I think many people are still using Python 2.5 because of Google App > Engine and fixing bugs with 2.5 is still helpful. > I don't think they'll be accepted. Python 2.5 is no

70% [* SPAM *] multiprocessing.Queue blocks when sending large object

2011-11-29 Thread DPalao
Hello, I'm trying to use multiprocessing to parallelize a code. There is a number of tasks (usually 12) that can be run independently. Each task produces a numpy array, and at the end, those arrays must be combined. I implemented this using Queues (multiprocessing.Queue): one for input and anoth

Re: cmd.Cmd asking questions?

2011-11-29 Thread Tim Chase
On 11/28/11 06:27, Robert Kern wrote: On 11/28/11 12:12 PM, Tim Chase wrote: I can monkey with printing messages and using raw_input(), but I'd like to know if there's a better way (such as something interacting with readline for text-entry-with-history-and-completion, If you import readline,

Total newbie question: Best practice

2011-11-29 Thread Colin Higwell
Hi, I am just starting to learn Python (I have been at it only a few hours), so please bear with me. I have a few very small scripts (do you call them scripts or programs?) which work properly, and produce the results intended. However, they are monolithic in nature; i.e. they begin at the beg

Re: Total newbie question: Best practice

2011-11-29 Thread Arnaud Delobelle
On 29 November 2011 20:06, Colin Higwell wrote: > Hi, Hi Colin, and welcome to Python :) > I am just starting to learn Python (I have been at it only a few hours), > so please bear with me. I have a few very small scripts (do you call them > scripts or programs?) which work properly, and produce

Re: Total newbie question: Best practice

2011-11-29 Thread Chris Angelico
On Wed, Nov 30, 2011 at 7:06 AM, Colin Higwell wrote: > However, they are monolithic in nature; i.e. they begin at the beginning > and finish at the end. Having done a little reading, I note that it seems > to be quite common to have a function main() at the start (which in turn > calls other func

Re: Total newbie question: Best practice

2011-11-29 Thread Neil Cerutti
On 2011-11-29, Arnaud Delobelle wrote: > As for the main() function, I don't think it is standard > practice in Python. There is no requirement to have a main() > function. You can use the idiom: I don't start off with a main function, but if my script gets long and complicated, or if global na

Re: Total newbie question: Best practice

2011-11-29 Thread Dave Angel
On 11/29/2011 03:06 PM, Colin Higwell wrote: Hi, I am just starting to learn Python (I have been at it only a few hours), so please bear with me. I have a few very small scripts (do you call them scripts or programs?) which work properly, and produce the results intended. However, they are mono

Programing Language: latitude-longitude-decimalize

2011-11-29 Thread Xah Lee
fun programing exercise. Write a function “latitude-longitude- decimalize”. It should take a string like this: 「"37°26′36.42″N 06°15′14.28″W"」. The return value should be a pair of numbers, like this: 「[37.44345 -6.25396]」. Feel free to use perl, python, ruby, lisp, etc. I'l

Re: Total newbie question: Best practice

2011-11-29 Thread Colin Higwell
On Tue, 29 Nov 2011 16:57:18 -0500, Dave Angel wrote: > On 11/29/2011 03:06 PM, Colin Higwell wrote: >> Hi, >> >> I am just starting to learn Python (I have been at it only a few >> hours), so please bear with me. I have a few very small scripts (do you >> call them scripts or programs?) which wor

Re: Programing Language: latitude-longitude-decimalize

2011-11-29 Thread Micky Hulse
Last time I did this was using AS3. The format I used was DMS: GPSLongitude: 122,42,47.79 GPSLongitudeRef: W GPSLatitude: 45,30,30.390001198897014 GPSLatitudeRef: N Here's the method: Not shown in above code: If West longitude or South latitude I would make tha

Re: Programing Language: latitude-longitude-decimalize

2011-11-29 Thread Ian Kelly
On Tue, Nov 29, 2011 at 3:53 PM, Xah Lee wrote: > fun programing exercise. Write a function “latitude-longitude- > decimalize”. > > It should take a string like this: 「"37°26′36.42″N 06°15′14.28″W"」. > The return value should be a pair of numbers, like this: 「[37.44345 > -6.253

Re: Programing Language: latitude-longitude-decimalize

2011-11-29 Thread Thad Floryan
On 11/29/2011 2:53 PM, Xah Lee wrote: > fun programing exercise. Write a function “latitude-longitude- > decimalize”. > > It should take a string like this: 「"37°26′36.42″N 06°15′14.28″W"」. > The return value should be a pair of numbers, like this: 「[37.44345 > -6.25396]」. >

Re: why is bytearray treated so inefficiently by pickle?

2011-11-29 Thread Irmen de Jong
On 28-11-2011 3:09, Terry Reedy wrote: > Possibly. The two developers listed as particularly interested in pickle are > 'alexandre.vassalotti,pitrou' (antoine), so if you do open a tracker issue, > add them as > nosy. > > Take a look at http://www.python.org/dev/peps/pep-3154/ > by Antoine Pitrou

pythoncom on Windows Server 2008

2011-11-29 Thread Nairn, Bruce
Hi, I'm trying to move some code to a Windows Server 2008 machine. It runs on Windows 7 and XP, but fails on Windows Server 2008. The python installation is seemingly identical (python 2.6.4, 32 bit). The following replicates the problem: import pythoncom IDispatch = pythoncom.CoCreateIns

Re: pythoncom on Windows Server 2008

2011-11-29 Thread Mark Hammond
On 30/11/2011 11:12 AM, Nairn, Bruce wrote: Hi, I’m trying to move some code to a Windows Server 2008 machine. It runs on Windows 7 and XP, but fails on Windows Server 2008. The python installation is seemingly identical (python 2.6.4, 32 bit). The following replicates the problem: import pytho

Re: Programing Language: latitude-longitude-decimalize

2011-11-29 Thread J�rgen Exner
Thad Floryan wrote: >On 11/29/2011 2:53 PM, Xah Lee wrote: Please do not reply to the eternal troll Thanks jue -- http://mail.python.org/mailman/listinfo/python-list

Re: Programing Language: latitude-longitude-decimalize

2011-11-29 Thread Thad Floryan
On 11/29/2011 5:14 PM, Jürgen Exner wrote: > Thad Floryan wrote: >> On 11/29/2011 2:53 PM, Xah Lee wrote: > > Please do not reply to the eternal troll > > Thanks Mea culpa, you're correct. I responded only because the subject is something with which I'm familiar, e.g., one of my posts from 19

Re: cmd.Cmd asking questions?

2011-11-29 Thread Cameron Simpson
On 29Nov2011 13:37, Tim Chase wrote: | On 11/28/11 06:27, Robert Kern wrote: [...] | >I actually have a preference for needing to press enter for | >Y/N answers, too. It's distinctly *less* uniform to have some | >questions requiring an enter and some not. It can be | >unpleasantly surprising to t

Converting MS Access DB to Postgres or MySQL for ORM support with SQLalchemy

2011-11-29 Thread Alec Taylor
Good afternoon, I was recently shown that my client runs MS Access everywhere, rather than a "real" database. There are many features they would be missing that something like a django frontend would provide. So I would like to move them to Postgres or MySQL (since MS Access support was been drop

How convert a list string to a real list

2011-11-29 Thread 郭军权
Good after I have a string liststr = '["","","ccc"]' ,and I need convert it to a list like list = ["","","ccc"],what can id do? Thanks. -- 郭军权 清华大学网络中心网络安全实验室 guojunquan{at}gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: How convert a list string to a real list

2011-11-29 Thread Alec Taylor
import json s = json.dumps([1, 2, 3, 4]) # '[1, 2, 3, 4]' l = json.loads(s) # [1, 2, 3, 4] 2011/11/30 郭军权 : > Good after > I have a string liststr = '["","","ccc"]' ,and I need convert > it to a list like list = ["","","ccc"],what can id do? > Thanks. > > > -- > 郭军权 > 清华大学网络中

Re: How convert a list string to a real list

2011-11-29 Thread Terry Reedy
On 11/30/2011 1:20 AM, 郭军权 wrote: Good after I have a string liststr = '["","","ccc"]' ,and I need convert it to a list like list = ["","","ccc"],what can id do? The easiest -- and most dangerous -- way is >>> eval('["","","ccc"]') ['', '', 'ccc'] But DO NOT eva

Re: How convert a list string to a real list

2011-11-29 Thread Arnaud Delobelle
On Nov 30, 2011 6:21 AM, "郭军权" wrote: > > Good after > I have a string liststr = '["","","ccc"]' ,and I need convert it to a list like list = ["","","ccc"],what can id do? > Thanks. > Look up the json module. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list

Re: How convert a list string to a real list

2011-11-29 Thread Alec Taylor
Arnaud: Already showed that solution On Wed, Nov 30, 2011 at 6:09 PM, Arnaud Delobelle wrote: > > On Nov 30, 2011 6:21 AM, "郭军权" wrote: >> >> Good after >>     I have a string  liststr = '["","","ccc"]' ,and I need convert >> it to a list like list = ["","","ccc"],what can id do?