Re: A useful, but painful, one-liner to edit money amounts

2010-08-04 Thread Peter Otten
John Nagle wrote: > There's got to be a better way to do this: > > > def editmoney(n) : > return((",".join(reduce(lambda lst, item : (lst + [item]) if > item else lst, > re.split(r'(\d\d\d)',str(n)[::-1]),[])))[::-1]) > > > >>> editmoney(0) > '0' > >>> editmoney(13535)

Re: newbie problem with str.replace

2010-08-04 Thread Daniel da Silva
Also, for bestandsnaam in dirs and files: is probably not doing what you want. Use + to concatenate lists. Daniel On Wed, Aug 4, 2010 at 6:30 AM, Mike Kent wrote: > On Aug 4, 9:10 am, BobAalsma wrote: > > I'm working on a set of scripts and I can't get a replace to work in >

Re: A useful, but painful, one-liner to edit money amounts

2010-08-04 Thread Steven D'Aprano
On Wed, 04 Aug 2010 21:33:31 -0700, John Nagle wrote: > There's got to be a better way to do this: > > > def editmoney(n) : > return((",".join(reduce(lambda lst, item : (lst + [item]) if > item else lst, > re.split(r'(\d\d\d)',str(n)[::-1]),[])))[::-1]) What does the name

Re: A useful, but painful, one-liner to edit money amounts

2010-08-04 Thread Paul Rubin
John Nagle writes: > def editmoney(n) : > return((",".join(reduce(lambda lst, item : (lst + [item]) if > item else lst, > re.split(r'(\d\d\d)',str(n)[::-1]),[])))[::-1]) Too obscure. I usually use something like this: def editmoney(n): if n < 0: return '-' + edit

Re: simple (I hope!) problem

2010-08-04 Thread samwyse
On Aug 3, 1:20 am, Steven D'Aprano wrote: > On Mon, 02 Aug 2010 17:19:46 -0700, samwyse wrote: > > Fortunately, I don't need the functionality of the object, I just want > > something that won't generate an error when I use it.  So, what is the > > quickest way to to create such an object (replaci

A useful, but painful, one-liner to edit money amounts

2010-08-04 Thread John Nagle
There's got to be a better way to do this: def editmoney(n) : return((",".join(reduce(lambda lst, item : (lst + [item]) if item else lst, re.split(r'(\d\d\d)',str(n)[::-1]),[])))[::-1]) >>> editmoney(0) '0' >>> editmoney(13535) '13,535' >>> editmoney(-14535) '-14,535' >>> e

100% without investment online part time jobs..(adsense, datawork, neobux..more jobs)

2010-08-04 Thread rosy us
100% without investment….no registration fee…no need money… Online part time jobs…(googleadsense, dataentry…etc)all type of jobs… work from home..daily 2-3 hours…earn more money without any risk.. Full details at http://adsensejobworkfulldetails.co.cc/ More adsense tips,secrets,increasing

Re: __init__ as a lambda

2010-08-04 Thread Steven D'Aprano
On Wed, 04 Aug 2010 12:58:18 -0700, Eric J. Van der Velden wrote: > Hello, > > Suppose > > class C: > def __init__(self,name):self.name=name > > I was wondering if I could make the __init__ a lambda function, Of course you can. Lambdas aren't special types of functions, they are *syntax* for

Re: Why is python not written in C++ ?

2010-08-04 Thread Roy Smith
In article , Lawrence D'Oliveiro wrote: > In message , Grant Edwards wrote: > > > The problem has nothing to do with the relative merits of the > > languages. The problem is inertia. > > So how was C++ able to get popular in the first place? And how was Java able > to grab some share from it

Re: Why is there no platform independent way of clearing a terminal?

2010-08-04 Thread David Robinow
On Wed, Aug 4, 2010 at 6:47 PM, Lawrence D'Oliveiro wrote: > In message , David > Robinow wrote: > >>  As an admittedly stupid comparison, I have 1579 DLLs in my >> \windows\system32 directory. >> Some number of these have been upgraded by Windows Update. > > What about the ones that aren’t? How d

Re: Why is python not written in C++ ?

2010-08-04 Thread Carl Banks
On Aug 4, 4:23 pm, Paul Rubin wrote: > Java was also on the OO bandwagon of the 1990's, which > translated into good marketing back then, but is part of the cause of > the massive bureaucracy and bloat in the Java runtime environment.  C++ > seems to have made something of a comeback because of th

Re: Why is python not written in C++ ?

2010-08-04 Thread Carl Banks
On Aug 4, 4:04 pm, Grant Edwards wrote: > On 2010-08-04, Lawrence D'Oliveiro wrote: > > > In message , Grant Edwards wrote: > > >> The problem has nothing to do with the relative merits of the > >> languages.  The problem is inertia. > > > So how was C++ able to get popular in the first place? >

Re: Package management

2010-08-04 Thread Lawrence D'Oliveiro
In message <87pqxy2aqd@benfinney.id.au>, Ben Finney wrote: > Have you ever tried to make such a package and get it into Debian? I have found it very easy to recreate the same steps used by the package maintainers. For instance, “apt-get source ” brings down the exact same source files used

Re: Package management

2010-08-04 Thread Ben Finney
Lawrence D'Oliveiro writes: > In message <87aap44mc7.fsf...@benfinney.id.au>, Ben Finney wrote: > > > Sadly, Python's package management is rather lacking by these > > standards. The Distutils legacy assumption of “package recipient, > > system administrator, and end user are all the same person”

Struggling to convert a mysql datetime object to a python string of a different format

2010-08-04 Thread Νίκος
Okey, i have many hours now struggling to convert a mysql datetime field that i retreive to a string of this format '%d %b, %H:%M' I google a lot but couldnt found out how to format it being a string Here si the code so far: try: cursor.execute( ''' SELECT host, hits, dat

Re: __init__ as a lambda

2010-08-04 Thread John Nagle
On 8/4/2010 12:58 PM, Eric J. Van der Velden wrote: Hello, Suppose class C: def __init__(self,name):self.name=name I was wondering if I could make the __init__ a lambda Python is not a functional language. Attempts to make it one make it worse. There's this mindset that loops are

Re: Why is python not written in C++ ?

2010-08-04 Thread Paul Rubin
Lawrence D'Oliveiro writes: > So how was C++ able to get popular in the first place? And how was > Java able to grab some share from it? C++ made improvements over C that were necessary and welcome for controlling the complexity of large programs, while remaining mostly upward compatible with C.

Re: how to pretty-print Python dict with unicode?

2010-08-04 Thread Vlastimil Brom
2010/8/5 kj : > > Is there a simple way to get Python to pretty-print a dict whose > values contain Unicode? (Of course, the goal here is that these > printed values are human-readable.) > > If I run the following simple script: > > from pprint import pprint > x = u'\u6c17\u304c\u9055\u3046' > pri

Re: how to pretty-print Python dict with unicode?

2010-08-04 Thread Benjamin Kaplan
On Wed, Aug 4, 2010 at 3:15 PM, kj wrote: > > > > Is there a simple way to get Python to pretty-print a dict whose > values contain Unicode?  (Of course, the goal here is that these > printed values are human-readable.) > > If I run the following simple script: > > from pprint import pprint > x =

adding optionMenu items in code

2010-08-04 Thread Chris Hare
I have an option menu self.w = OptionMenu(self.frameNewNet, self.variable, "one", "two", "three") Is there a way to add items to this programmatically, i.e. using values from a database? -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is python not written in C++ ?

2010-08-04 Thread Grant Edwards
On 2010-08-04, Lawrence D'Oliveiro wrote: > In message , Grant Edwards wrote: > >> The problem has nothing to do with the relative merits of the >> languages. The problem is inertia. > > So how was C++ able to get popular in the first place? Building on C's popularity helped. > And how was Java

Re: __init__ as a lambda

2010-08-04 Thread Carl Banks
On Aug 4, 12:58 pm, "Eric J. Van der Velden" wrote: > Hello, > > Suppose > > class C: >  def __init__(self,name):self.name=name > > I was wondering if I could make the __init__ a lambda function, but > > class C: >  __init__=lambda self,self.name:None > > and then later, > > C('Hello') > > does no

Re: Why is python not written in C++ ?

2010-08-04 Thread Paul Rubin
Lawrence D'Oliveiro writes: > > The Ada 2012 Language Reference Manual is 860 pages ... > Yeah, unfortunately the language was designed by a committee ... > It seems apt to describe the resulting design as “bulletproof”, but > “elegant” or “concise” ... not so much. I'd say the Ada standardizers

Questions, newbies, and community (was: python terminology on classes)

2010-08-04 Thread Ben Finney
"Rhodri James" writes: > On Wed, 04 Aug 2010 19:28:48 +0100, Steve Ferg > wrote: > > >> Seriously, we can't keep doing your thinking for you. The answers > >> to all your questions are section 9 of the tutorial. > > > > This is is just the kind of newbie-hostile smart-ass reply that we do > > no

Re: Package management (was: Why is there no platform independent way of clearing a terminal?)

2010-08-04 Thread Lawrence D'Oliveiro
In message <87aap44mc7.fsf...@benfinney.id.au>, Ben Finney wrote: > Sadly, Python's package management is rather lacking by these standards. > The Distutils legacy assumption of “package recipient, system > administrator, and end user are all the same person”, among other design > decisions, makes

Re: Why is there no platform independent way of clearing a terminal?

2010-08-04 Thread Lawrence D'Oliveiro
In message , David Robinow wrote: > As an admittedly stupid comparison, I have 1579 DLLs in my > \windows\system32 directory. > Some number of these have been upgraded by Windows Update. What about the ones that aren’t? How do you maintain those? -- http://mail.python.org/mailman/listinfo/pyth

Re: Why is python not written in C++ ?

2010-08-04 Thread Lawrence D'Oliveiro
In message , Grant Edwards wrote: > The problem has nothing to do with the relative merits of the > languages. The problem is inertia. So how was C++ able to get popular in the first place? And how was Java able to grab some share from it? -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is python not written in C++ ?

2010-08-04 Thread Lawrence D'Oliveiro
In message , Grant Edwards wrote: > In my experience, the hiring issue is "we're already behind schedule > and short-handed, we don't have the time or resources to teach people > a new language." Most people seem to need tutorials or handholding of some sort. Look at the number of questions in t

Re: __init__ as a lambda

2010-08-04 Thread Stefan Schwarzer
Hi Eric, On 2010-08-04 21:58, Eric J. Van der Velden wrote: > class C: > def __init__(self,name):self.name=name > > I was wondering if I could make the __init__ a lambda function, but > > class C: > __init__=lambda self,self.name:None > > and then later, > > C('Hello') > > does not work; th

Re: python terminology on classes

2010-08-04 Thread Rhodri James
On Wed, 04 Aug 2010 19:28:48 +0100, Steve Ferg wrote: Seriously, we can't keep doing your thinking for you. The answers to all your questions are section 9 of the tutorial. This is is just the kind of newbie-hostile smart-ass reply that we do not want to see on comp.lang.python. Let's try

Python 2.6.6 release candidate 1 now available

2010-08-04 Thread Barry Warsaw
Hello fellow Pythoneers and Pythonistas, The source tarballs and Windows installers for the first (and hopefully only) Python 2.6.6 release candidate is now available: http://www.python.org/download/releases/2.6.6/ As usual, we would love it if you could download, install, and test these wit

Re: Unicode error

2010-08-04 Thread Aahz
In article , Nobody wrote: > >Java's checked exception mechanism was based on real-world experience of >the pitfalls of abstract types. And that experience was gained in >environments where interface specifications were far more detailed than is >the norm in the Python world. There are a number

how to pretty-print Python dict with unicode?

2010-08-04 Thread kj
Is there a simple way to get Python to pretty-print a dict whose values contain Unicode? (Of course, the goal here is that these printed values are human-readable.) If I run the following simple script: from pprint import pprint x = u'\u6c17\u304c\u9055\u3046' print '{%s: %s}' % (u'x', x) pri

scipy / stats : quantiles using sample weights from survey data

2010-08-04 Thread Christopher Barrington-Leigh
There is a function scipy.stats.mstats.mquantiles that returns quantiles for a vector of data. But my data should not be uniformly weighted in an estimate of the distribution, since they are from a survey and come with estimated sampling weights based on the stratification used in sampling. Is th

Re: XML parsing: SAX/expat & yield

2010-08-04 Thread kj
In Peter Otten <__pete...@web.de> writes: >How about >http://effbot.org/zone/element-iterparse.htm#incremental-parsing Exactly! Thanks! ~K -- http://mail.python.org/mailman/listinfo/python-list

[ANN] Websourcebrowser 0.4a released

2010-08-04 Thread Stefan Schwarzer
Hello, I'm happy to announce the release of Websourcebrowser 0.4a. Websourcebrowser is a program intended to get a quick overview of a project's source code. The program is controlled from a web browser which displays a directory tree and a source code file side by side. The homepage of the proj

Re: BundleBuilder Question

2010-08-04 Thread Ned Deily
In article <20100804200820.1ir1h.80013.r...@cdptpa-web19-z02>, wrote: > I stumbled upon an article about bundlebuilder, so I was testing it a little. > At first it wouldn't work and had this in the error: > > IOError: [Errno 2] No such file or directory: > '/System/Library/Frameworks/Python.

A new syntax for writing tests

2010-08-04 Thread Jonathan Fine
Hi I just discovered today a new syntax for writing tests. The basic idea is to write a function that contains some statements, and run it via a decorator. I wonder if anyone had seen this pattern before, and how you feel about it. For myself, I quite like it. Let's suppose we want to tes

Re: None is negative?

2010-08-04 Thread Thomas Jollans
On 08/03/2010 10:17 PM, wheres pythonmonks wrote: > I did the google search... I must be blind as I don't see any hits... > > None is negative in Python? (v2.6) > > http://www.google.com/search?ie=UTF-8&q=%22none+is+negative%22+python > if None < -999.99: print "hi" > > hi > >>>

Re: running a piece of code at specific intervals?

2010-08-04 Thread Jesse Jaggars
On Wed, Aug 4, 2010 at 2:44 PM, Chris Hare wrote: > Don't say cron : > > I want to have a section of my code executed at 15 minute intervals.  I am > using Threading.timer, but it is causing a problem sinxe I am using sqlite3 > and the thread support gives me an error, which aborts part of my co

BundleBuilder Question

2010-08-04 Thread jyoung79
I stumbled upon an article about bundlebuilder, so I was testing it a little. At first it wouldn't work and had this in the error: IOError: [Errno 2] No such file or directory: '/System/Library/Frameworks/Python.framework/Versions/2.6/Resources/English.lproj' I'm currently running OS X 10.6 wi

Re: running a piece of code at specific intervals?

2010-08-04 Thread Dave Angel
Chris Hare wrote: Don't say cron : I want to have a section of my code executed at 15 minute intervals. I am using Threading.timer, but it is causing a problem sinxe I am using sqlite3 and the thread support gives me an error, which aborts part of my code. So, is there an alternative to thre

__init__ as a lambda

2010-08-04 Thread Eric J. Van der Velden
Hello, Suppose class C: def __init__(self,name):self.name=name I was wondering if I could make the __init__ a lambda function, but class C: __init__=lambda self,self.name:None and then later, C('Hello') does not work; the first argument, self, is assigned all rigth, but you cannot write th

running a piece of code at specific intervals?

2010-08-04 Thread Chris Hare
Don't say cron : I want to have a section of my code executed at 15 minute intervals. I am using Threading.timer, but it is causing a problem sinxe I am using sqlite3 and the thread support gives me an error, which aborts part of my code. So, is there an alternative to threading.timer?

Re: The Application cannot locate win32ui.pyd (or Python) (126)

2010-08-04 Thread vsoler
On Aug 4, 7:52 pm, Alex Willmer wrote: > On Aug 4, 5:19 pm, vsoler wrote: > > > > > On Aug 4, 5:41 pm, Alex Willmer wrote: > > > > On Aug 4, 2:35 pm, vsoler wrote: > > > > > Hi all, > > > > > I just installed python 3.1.2 where I used to have python 2.6.4. I'm > > > > working on Win7. > > > > >

Re: python terminology on classes

2010-08-04 Thread Steve Ferg
> Seriously, we can't keep doing your thinking for you.  The answers > to all your questions are section 9 of the tutorial. This is is just the kind of newbie-hostile smart-ass reply that we do not want to see on comp.lang.python. Let's try again: I think that the answers to all your questions a

Re: Trying to set a cookie within a python script

2010-08-04 Thread donn
On 04/08/2010 20:09, Dotan Cohen wrote: Don't forget that the Euro symbol is outside the Greek character set. I could make some kind of economic joke here, but I'm also broke :D \d -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to set a cookie within a python script

2010-08-04 Thread Dotan Cohen
On Wed, Aug 4, 2010 at 18:30, Dave Angel wrote: > Depends on how sure you are that your program will never need characters > outside your greek character set. Remember Y2K? > Don't forget that the Euro symbol is outside the Greek character set. -- Dotan Cohen http://gibberish.co.il http://what

Re: The Application cannot locate win32ui.pyd (or Python) (126)

2010-08-04 Thread Alex Willmer
On Aug 4, 5:19 pm, vsoler wrote: > On Aug 4, 5:41 pm, Alex Willmer wrote: > > > > > > > On Aug 4, 2:35 pm, vsoler wrote: > > > > Hi all, > > > > I just installed python 3.1.2 where I used to have python 2.6.4. I'm > > > working on Win7. > > > > The IDLE GUI works, but I get the following message

Re: XML parsing: SAX/expat & yield

2010-08-04 Thread Peter Otten
kj wrote: > I want to write code that parses a file that is far bigger than > the amount of memory I can count on. Therefore, I want to stay as > far away as possible from anything that produces a memory-resident > DOM tree. > > The top-level structure of this xml is very simple: it's just a > v

XML parsing: SAX/expat & yield

2010-08-04 Thread kj
I want to write code that parses a file that is far bigger than the amount of memory I can count on. Therefore, I want to stay as far away as possible from anything that produces a memory-resident DOM tree. The top-level structure of this xml is very simple: it's just a very long list of "reco

Re: parsing a c project

2010-08-04 Thread Eli Bendersky
On Wed, Aug 4, 2010 at 14:33, Aitor Garcia wrote: > Hi, > > I need to know the memory locations of all variables in a C project > including > variables allocated inside structs. > Aitor, try the pycparser project (http://code.google.com/p/pycparser/) - it's a complete ISO C parser in pure Python

problem adding a scrollbar to a text widget

2010-08-04 Thread Chris Hare
Here is my chunk of code. I can't figure out what I am doing wrong to put my scrollbar on the right hand side of the text box. from Tkinter import * def showLogFile(): top = Toplevel() f = Frame(top, bd=0, bg="Gray") top.title = "netcomm log file" f.grid() sc = Scrollbar(top

Re: The Application cannot locate win32ui.pyd (or Python) (126)

2010-08-04 Thread vsoler
On Aug 4, 5:41 pm, Alex Willmer wrote: > On Aug 4, 2:35 pm, vsoler wrote: > > > Hi all, > > > I just installed python 3.1.2 where I used to have python 2.6.4. I'm > > working on Win7. > > > The IDLE GUI works, but I get the following message when trying to > > open *.py files written for py 2.6 >

Re: error: (113, 'Software caused connection abort')0

2010-08-04 Thread Aahz
In article , sarah wrote: > > i face with this problem when i want to run this command on cygwin: > python httpd.py 8000 example-300-1k-rigid.py Make sure the webclient service is running. (May not have anything to do with your problem, but it's something I had a problem with recently.) --

Re: The Application cannot locate win32ui.pyd (or Python) (126)

2010-08-04 Thread Alex Willmer
On Aug 4, 2:35 pm, vsoler wrote: > Hi all, > > I just installed python 3.1.2 where I used to have python 2.6.4. I'm > working on Win7. > > The IDLE GUI works, but I get the following message when trying to > open *.py files written for py 2.6 > >         The Application cannot locate win32ui.pyd (

Re: Get name of file from directory into variable

2010-08-04 Thread Steven W. Orr
On 08/03/10 06:21, quoth loial: > In a unix shell script I can do something like this to look in a > directory and get the name of a file or files into a variable : > > MYFILE=`ls /home/mydir/JOHN*.xml` > > > Can I do this in one line in python? > Sorry, but I just can't help myself. Yeah, it

Re: Trying to set a cookie within a python script

2010-08-04 Thread Dave Angel
¯º¿Â wrote: On 3 Αύγ, 21:00, Dave Angel wrote: A string is an object containing characters. A string literal is one of the ways you create such an object. When you create it that way, you need to make sure the compiler knows the correct encoding, by using the encoding: line at begi

Re: Why is python not written in C++ ?

2010-08-04 Thread Grant Edwards
On 2010-08-04, Neil Hodgson wrote: > Grant Edwards: > >> That said, the last time I looked the Ada spec was only something like >> 100 pages long, so a case could be made that it won't take long to >> learn. I don't know how long the C++ language spec is, but I'm >> betting it's closer to 1000 th

Re: Why is python not written in C++ ?

2010-08-04 Thread Grant Edwards
On 2010-08-04, Paul Rubin wrote: > I'm not sure what the hiring issue is. I think anyone skilled in C++ > or Java can pick up Ada pretty easily. It's mostly a subset of C++ > with different surface syntax. In my experience, the hiring issue is "we're already behind schedule and short-handed, w

Re: Why is python not written in C++ ?

2010-08-04 Thread Grant Edwards
On 2010-08-04, Paul Rubin wrote: > Grant Edwards writes: >> The issue that would prevent its use where I work is the inability to >> hire anybody who knows Ada. ... >> That said, the last time I looked the Ada spec was only something like >> 100 pages long, so a case could be made that it won't

Re: parsing a c project

2010-08-04 Thread Jon Clements
On 4 Aug, 12:33, Aitor Garcia wrote: > Hi, > > I need to know the memory locations of all variables in a C project including > variables allocated inside structs. Pray tell us why? > > What I want to do in to expand the structs into its basic elements (floats, > int16 and int8). > > In a  header

The Application cannot locate win32ui.pyd (or Python) (126)

2010-08-04 Thread vsoler
Hi all, I just installed python 3.1.2 where I used to have python 2.6.4. I'm working on Win7. The IDLE GUI works, but I get the following message when trying to open *.py files written for py 2.6 The Application cannot locate win32ui.pyd (or Python) (126) Should I change the PATH in Win

Re: newbie problem with str.replace

2010-08-04 Thread Mike Kent
On Aug 4, 9:10 am, BobAalsma wrote: > I'm working on a set of scripts and I can't get a replace to work in > the script - please help. >                         bestandsnaam_nieuw.replace(KLANTNAAM_OUT,KLANTNAAM_IN) I'm not sure what you are intending to do here, but string.replace does not do i

Re: newbie problem with str.replace

2010-08-04 Thread BobAalsma
On Aug 4, 3:22 pm, Anthony Tolle wrote: > On Aug 4, 9:10 am, BobAalsma wrote: > > >                         # > >                         bestandsnaam_nieuw = bestandsnaam > >                         > > bestandsnaam_nieuw.replace(KLANTNAAM_OUT,KLANTNAAM_IN) > > The replace method does not modif

Re: newbie problem with str.replace

2010-08-04 Thread Peter Otten
BobAalsma wrote: Although [it] may not be obvious at first unless you're Dutch... > bestandsnaam_nieuw = bestandsnaam > bestandsnaam_nieuw.replace(KLANTNAAM_OUT,KLANTNAAM_IN) str.replace() does not modify a string, it creates a new one. This doesn't work: >>> s = "that's all folks" >>> s.repl

Re: newbie problem with str.replace

2010-08-04 Thread Anthony Tolle
On Aug 4, 9:10 am, BobAalsma wrote: >                         # >                         bestandsnaam_nieuw = bestandsnaam >                         bestandsnaam_nieuw.replace(KLANTNAAM_OUT,KLANTNAAM_IN) The replace method does not modify the string (strings are immutable). You need to use the

newbie problem with str.replace

2010-08-04 Thread BobAalsma
I'm working on a set of scripts and I can't get a replace to work in the script - please help. The scripts show no errors, work properly apart from the replace, all variables are filled as expected, the scripts works properly when the commands are copied to the Python shell. Text Main: .. from Le

Re: Python package to read .7z archives?

2010-08-04 Thread Hallvard B Furuseth
Giampaolo Rodolà writes: > 2010/8/4 Hallvard B Furuseth : >> Is there an equivalent of zipfile.py for .7z archives? >> I have one which extracts an archive member by running 7z e -so, >> but that's a *slow* way to read one file at a time. >> >> Google found me some python interfaces to lzma, but a

Re: lpr via subprocess in 2.4

2010-08-04 Thread James Mills
On Wed, Aug 4, 2010 at 9:38 PM, loial wrote: > I have also been trying to get the return code and standard error. p = Popen("..., stderr=PIPE) Look up the docs for subprocess.Popen cheers James -- -- James Mills -- -- "Problems are solved by method" -- http://mail.python.org/mailman/listinfo

Re: lpr via subprocess in 2.4

2010-08-04 Thread loial
Thanks...that worked. I have also been trying to get the return code and standard error. How do I access these? #!/usr/bin/python import os import subprocess process=subprocess.Popen(['lpr', '-P' ,'raserlpr','/etc/hosts'], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) print proce

parsing a c project

2010-08-04 Thread Aitor Garcia
Hi, I need to know the memory locations of all variables in a C project including variables allocated inside structs. What I want to do in to expand the structs into its basic elements (floats, int16 and int8). In a header file (example.h) I have the following definitions. struct house{ flo

Re: Python package to read .7z archives?

2010-08-04 Thread Giampaolo Rodolà
2010/8/4 Hallvard B Furuseth : > Is there an equivalent of zipfile.py for .7z archives? > I have one which extracts an archive member by running 7z e -so, > but that's a *slow* way to read one file at a time. > > Google found me some python interfaces to lzma, but apparently they > only handle sing

Re: lpr via subprocess in 2.4

2010-08-04 Thread Peter Otten
loial wrote: > I am am trying to run the following command via subprocess > > lpr -P printqueue filetoprint > > I cannot seem to get it to work and return stderr > > I think the issue is how to specify the arguments > > I am trying > > subprocess.Popen(['lpr -P' ,'laserlpr','/etc/hosts'], she

Python package to read .7z archives?

2010-08-04 Thread Hallvard B Furuseth
Is there an equivalent of zipfile.py for .7z archives? I have one which extracts an archive member by running 7z e -so, but that's a *slow* way to read one file at a time. Google found me some python interfaces to lzma, but apparently they only handle single compressed files, not .7z archives. (A

lpr via subprocess in 2.4

2010-08-04 Thread loial
I am am trying to run the following command via subprocess lpr -P printqueue filetoprint I cannot seem to get it to work and return stderr I think the issue is how to specify the arguments I am trying subprocess.Popen(['lpr -P' ,'laserlpr','/etc/hosts'], shell=False) but get error : Tracebac

Re: Difference between queues and pipes in multiprocessing

2010-08-04 Thread James Mills
On Wed, Aug 4, 2010 at 7:20 PM, Navkirat Singh wrote: > I was wondering what are the differences between queues and pipes implemented > using multiprocessing python module. Am I correct if I say, in pipes, if > another process writes to one receiving end concurrently, then an error will > be ra

Re: Trying to set a cookie within a python script

2010-08-04 Thread Steven D'Aprano
On Tue, 03 Aug 2010 20:08:46 -0700, Νίκος wrote: > i tried in IDLE enviroment as well and for some reason even with a > single number isnated of time() function the cookie is never set, > because the print of > print os.environ.get('HTTP_COOKIE') > > result to > > None What happens if you

Re: Python Script Cannot Write to Directory

2010-08-04 Thread Steven D'Aprano
On Tue, 03 Aug 2010 21:01:38 -0700, Chris Brauchli wrote: > Hi, > > I am writing a script that, at one point, copies a file from directory A > to directory B. Directory B can only be written to by root, but the > script is always called with sudo, so this shouldn't be an issue, but it > is. I hav

Re: Global variables problem

2010-08-04 Thread Jean-Michel Pichavant
Navkirat Singh wrote: On 04-Aug-2010, at 9:46 AM, Daniel da Silva wrote: Please post approximate code that actually works and displays the problem. On Tue, Aug 3, 2010 at 9:00 PM, Navkirat Singh > wrote: Hey guys, I am using a multiprocessing program, w

Difference between queues and pipes in multiprocessing

2010-08-04 Thread Navkirat Singh
Hi, I was wondering what are the differences between queues and pipes implemented using multiprocessing python module. Am I correct if I say, in pipes, if another process writes to one receiving end concurrently, then an error will be raised and in queues the later processes data will just que

Re: Why is python not written in C++ ?

2010-08-04 Thread Jean-Michel Pichavant
Carl Banks wrote: On Aug 3, 7:07 pm, Paul Rubin wrote: Mozilla is fed up with C++ and seems to be working on its own language, called Rust: http://lambda-the-ultimate.org/node/4009 That looks much better than Go. It's like all the cool features of Go without the annoying polemics

error: (113, 'Software caused connection abort')0

2010-08-04 Thread sarah
hi i face with this problem when i want to run this command on cygwin: python httpd.py 8000 example-300-1k-rigid.py Dfghfji12d52s35s2sswee9E with this error :0 Exception happened during processing of request from ('127.0.0.1', 35868) Traceback (most recent call last): File "/usr/local/lib/p

Re: Why is python not written in C++ ?

2010-08-04 Thread Lawrence D'Oliveiro
In message <7d95c0d3-718d-4958-9364-263c833f1...@i24g2000yqa.googlegroups.com>, sturlamolden wrote: > This is unsafe, anyone who writes this in C++ should be flogged: Only if they’re using exceptions. Otherwise, it’s fine. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Script Cannot Write to Directory

2010-08-04 Thread Matteo Landi
On Wed, Aug 4, 2010 at 9:27 AM, Chris Rebert wrote: > On Wed, Aug 4, 2010 at 12:21 AM, News123 wrote: > >> 3.) try following python >> >> import os >> print os.getcwd() >> import shutil >> shutil("YOUR_SOURCE_FILE_NAME","DESTINATION_DIRECTORY/DSTNTN_FILE_NAME") > > WTF; modules aren't callable.

Re: Why is python not written in C++ ?

2010-08-04 Thread Lawrence D'Oliveiro
In message , Nobody wrote: > One feature which can't readily be implemented in C is the automatic > clean-up side of the RAII idiom. Use do-once blocks . -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is python not written in C++ ?

2010-08-04 Thread Lawrence D'Oliveiro
In message , Neil Hodgson wrote: >The Ada 2012 Language Reference Manual is 860 pages and the Ada 2005 > LRM was 790 pages. The annotated versions are even longer > http://www.ada-auth.org/standards/ada12.html Yeah, unfortunately the language was designed by a committee which was trying to

Re: Global variables problem

2010-08-04 Thread Matteo Landi
Usually, modify global variables in a multi-thread/multi-process scenario is not the right to operate: you better re-implement your solution in a way that the shared resource is either protected with synchronized objects or accessed by a single thread/process (and in this case, it won't be a share

Re: Trying to set a cookie within a python script

2010-08-04 Thread Dotan Cohen
2010/8/4 Νίκος : > Encodings still give me headaches. I try to understand them as > different ways to store data in a media. > > Tell me something. What encoding should i pick for my scripts knowing > that only contain english + greek chars?? > iso-8859-7 or utf-8 and why? > Always use UTF-8, ever

Re: Urrlib2 IncompleteRead error

2010-08-04 Thread Gabriel Genellina
On 27 jul, 11:00, dirknbr wrote: > I am running urllib2.request and get this response when I do the read. > Any ideas what causes this? > > return response.read() >   File "C:\Python26\lib\socket.py", line 329, in read >     data = self._sock.recv(rbufsize) >   File "C:\Python26\lib\httplib.py",

Re: Global variables problem

2010-08-04 Thread Navkirat Singh
: ( False alarm, the earlier solution breaks multiprocessing. Whats happening here is the child needs to change a variable in the parent process, So I think I am looking at shared memory (maybe). Any suggestions? Regards, Nav On 04-Aug-2010, at 12:41 PM, Navkirat Singh wrote: > Thanks a l

Re: Python Script Cannot Write to Directory

2010-08-04 Thread Chris Rebert
On Wed, Aug 4, 2010 at 12:21 AM, News123 wrote: > 3.) try following python > > import os > print os.getcwd() > import shutil > shutil("YOUR_SOURCE_FILE_NAME","DESTINATION_DIRECTORY/DSTNTN_FILE_NAME") WTF; modules aren't callable. Typo? Cheers, Chris -- http://blog.rebertia.com -- http://mail.p

Re: Python Script Cannot Write to Directory

2010-08-04 Thread News123
On 08/04/2010 06:01 AM, Chris Brauchli wrote: > Hi, > > I am writing a script that, at one point, copies a file from directory > A to directory B. Directory B can only be written to by root, but the > script is always called with sudo, so this shouldn't be an issue, but > it is. I have tried using

Re: Global variables problem

2010-08-04 Thread Navkirat Singh
Thanks a lot guys !! I solved the problem: In the lines: >> new_process = process(target=newprocess) >>new_process.start() The target=newprocess is pointing towards a variable, instead of a function. So, appending a () will make it goto that function, thereby changing