Re: Getting Local MAC Address

2010-04-06 Thread Lawrence D'Oliveiro
In message , Booter wrote: > I am new to python ans was wondering if there was a way to get the mac > address from the local NIC? What if you have more than one? -- http://mail.python.org/mailman/listinfo/python-list

Re: local variable referenced before assignment

2010-04-06 Thread Steven D'Aprano
On Mon, 05 Apr 2010 10:08:51 -0700, John Nagle wrote: > Alf P. Steinbach wrote: > >> Best is however to recognize that you have some state (your variable) >> and some operations on that state (your callback), and that that is >> what objects are all about. I.e. wrap your logic in a class. Then >>

Re: PIL question

2010-04-06 Thread Peter Otten
Tim Eichholz wrote: > I'm trying to cut a BMP with 80 adjacent frames down to 40 using the > Image.copy and .paste functions but I'm getting error "ValueError: > images do not match" on the paste line. > newimage.paste(cols[f], (f*framew, 0, (f*framew)+192, 192)) The 4-tuple doesn't match the si

Re: folks, what's wrong with this?

2010-04-06 Thread Bruno Desthuilliers
Ani Sinha a écrit : And now for the most import point: __getattr__ is only called as a *last* resort. That is, after the attribute lookup mechanism will have tried *and failed* to find the name in the instance's __dict__. Thanks you all for all the suggestions and thoughts. So in other words, t

Re: In disGuiodoise?

2010-04-06 Thread Bruno Desthuilliers
r a écrit : (snip) * If he feeling like spreading propaganda he fires up the George Sakkis or Bruno Desthuilliers. ??? Thought most of my posts here were mostly in the "lame joke" category, with perhaps sometimes a more technical contribution, but "propaganda" ??? I think you're confusing m

Re: Incorrect scope of list comprehension variables

2010-04-06 Thread Alain Ketterlin
Alain Ketterlin writes: > d = dict() > for r in [1,2,3]: > d[r] = [r for r in [4,5,6]] > print d Thanks to Chris and Paul for the details (the list comp. r actually leaks). I should have found this by myself. My background is more on functional programming languages, that's why I thought th

Re: Incorrect scope of list comprehension variables

2010-04-06 Thread Alain Ketterlin
Steven D'Aprano writes: >> d = dict() >> for r in [1,2,3]: >> d[r] = [r for r in [4,5,6]] >> print d > > This isn't directly relevant to your problem, but why use a list > comprehension in the first place? [r for r in [4,5,6]] is just [4,5,6], > only slower. Sure. But I've actually spent s

Re: PIL question

2010-04-06 Thread Tim Eichholz
On Apr 6, 3:05 am, Peter Otten <__pete...@web.de> wrote: > Tim Eichholz wrote: > > I'm trying to cut a BMP with 80 adjacent frames down to 40 using the > > Image.copy and .paste functions but I'm getting error "ValueError: > > images do not match" on the paste line. > > newimage.paste(cols[f], (f*f

Re: PIL question

2010-04-06 Thread Peter Otten
Tim Eichholz wrote: > I think maybe I am using the wrong function. I want to paste the > entire 192x192 contents of cols[f] into newimage. I would think it > works like newimage.paste(cols[f], (x, 0, 192+x, 192)) if that's not > it I think I'm missing a function Don't "think"! Read the documentat

Re: Translation docstrings with gettext

2010-04-06 Thread sapient
Lie Ryan, thank you for your answer! > Why would you want to translate docstring? Docstring is meant for > developers not users. I have mentioned that I want to provide API for existing image- processing applicaion in Python. In my case "developers" are "users". Python provides great possibilities

Re: per-function jit compiler

2010-04-06 Thread Luis M . González
On 6 abr, 03:40, Chris Rebert wrote: > 2010/4/5 Luis M. González : > > > > > > > This post gave me an > > idea:http://groups.google.com/group/comp.lang.python/msg/5d75080707104b76 > > > What if I write a simple decorator to figure out the types of every > > function, and then we use it as a base

my threaded program hangs after calling Queue.join()

2010-04-06 Thread Babu
I am not an expert in python, so any help is my appreciated. My threaded program consumed everything in the queue but is not exiting... What is the problem with this program? #!/opt/gspython-2.5/bin/python """ Intention of this program: given a list of host names in a file, get the .rhosts file,

Re: case insensitive list ?

2010-04-06 Thread Stef Mientki
On 05-04-2010 19:23, Robert Kern wrote: > On 2010-04-05 12:17 PM, Stef Mientki wrote: >> hello, >> >> AFAIK there's no case insensitive list in Python. >> By case insentive I mean that that sort and memebr of is case >> insensitive. >> >> Does soeone has a implementation of sucha case insensitive l

Re: my threaded program hangs after calling Queue.join()

2010-04-06 Thread Kushal Kumaran
On Tue, Apr 6, 2010 at 5:36 PM, Babu wrote: > I am not an expert in python, so any help is my appreciated.  My > threaded program consumed everything in the queue but is not > exiting... What is the problem with this program? > See the example in the documentation of the queue module. There must

Re: my threaded program hangs after calling Queue.join()

2010-04-06 Thread Peter Otten
Babu wrote: > I am not an expert in python, so any help is my appreciated. My > threaded program consumed everything in the queue but is not > exiting... What is the problem with this program? Perhaps it's waiting for the task_done() call associated to the (None, None) pairs. >

Re: my threaded program hangs after calling Queue.join()

2010-04-06 Thread Babu
On Apr 6, 9:32 pm, Peter Otten <__pete...@web.de> wrote: > Babu wrote: > > I am not an expert in python, so any help is my appreciated.  My > > threaded program consumed everything in the queue but is not > > exiting... What is the problem with this program? > > Perhaps it's waiting for the task_do

Re: sum for sequences?

2010-04-06 Thread Albert van der Horst
In article <559a2ee3-fb2c-477f-a444-7edbb6da8...@r1g2000yqj.googlegroups.com>, Patrick Maupin wrote: >On Mar 29, 10:29=A0pm, Steven D'Aprano > wrote: >> On Mon, 29 Mar 2010 19:24:42 -0700, Patrick Maupin wrote: >> > On Mar 29, 6:19=A0pm, Steven D'Aprano > > cybersource.com.au> wrote: >> >> How do

Re: (a==b) ? 'Yes' : 'No'

2010-04-06 Thread Albert van der Horst
In article , Peter Otten <__pete...@web.de> wrote: >Pierre Quentel wrote: > >> I'm surprised nobody proposed a solution with itertools ;-) > >next(itertools.takewhile(lambda _: a == b, ["yes"]), "no") I could learn something here, if you explain it? > >You spoke to soon :) > >Peter Groetjes Alb

pass object or use self.object?

2010-04-06 Thread Tim Arnold
Hi, I have a few classes that manipulate documents. One is really a process that I use a class for just to bundle a bunch of functions together (and to keep my call signatures the same for each of my manipulator classes). So my question is whether it's bad practice to set things up so each method

Loading an imported module (C API)

2010-04-06 Thread booncw
Hi, I am running a simulation where the python module has already been imported. Could you please tell me how to load it? I've been doing this (importing everytime), but it is too slow: pModule = PyImport_Import(pName); Yours, Boon -- http://mail.python.org/mailman/listinfo/python-list

Re: sum for sequences?

2010-04-06 Thread Xavier Ho
On Tue, Apr 6, 2010 at 11:39 PM, Albert van der Horst < alb...@spenarnc.xs4all.nl> wrote: > Now for floating point numbers the order of summation is crucial, > not commutative (a+b)+c <> a+(b+c). > Could you shed some light on why is this? Cheers, Xav -- http://mail.python.org/mailman/listinfo

Re: pass object or use self.object?

2010-04-06 Thread Xavier Ho
> So my question is whether it's bad practice to set things up so each > method operates on self.document or should I pass document around from > one function to the next? > I think this depends on the use case. If the functions you're calling in between have a chance to be called independently,

Re: sum for sequences?

2010-04-06 Thread Patrick Maupin
On Apr 6, 8:39 am, Albert van der Horst wrote: > To a mathematician sum(set) suggest that the order of summation > doesn't matter. (So I wouldn't use sum for concatenating lists.) > Harshly, sum() should be used only for operator + both associative and > commutative. That's all well and good, bu

Re: (a==b) ? 'Yes' : 'No'

2010-04-06 Thread Albert van der Horst
In article , Steve Holden wrote: >kj wrote: >> In Steve Holden >> writes: >> >>> John Nagle wrote: Chris Rebert wrote: > On Tue, Mar 30, 2010 at 8:40 AM, gentlestone > wrote: >> Hi, how can I write the popular C/JAVA syntax in Python? >> >> Java example: >>ret

Re: sum for sequences?

2010-04-06 Thread Neil Cerutti
On 2010-04-06, Albert van der Horst wrote: > To a mathematician sum(set) suggest that the order of summation > doesn't matter. (So I wouldn't use sum for concatenating > lists.) Harshly, sum() should be used only for operator + both > associative and commutative. > > Now for floating point numbers

Recommend Commercial graphing library

2010-04-06 Thread AlienBaby
Hi, I'm on the hunt for a good quality commercially licensed graphing / plotting library and wondered if anyone here had any recomendations. The work to be done is less scientific, more presentational, (I'm not going to be dealing with heatmaps / vectors etc.., just the usual bar / line / bubble /

Re: pass object or use self.object?

2010-04-06 Thread Bruno Desthuilliers
Tim Arnold a écrit : Hi, I have a few classes that manipulate documents. One is really a process that I use a class for just to bundle a bunch of functions together (and to keep my call signatures the same for each of my manipulator classes). So my question is whether it's bad practice to set th

Re: Recommend Commercial graphing library

2010-04-06 Thread Pablo Recio Quijano
Why must be commercial, when there is open and free alternatives? Like GNU Plot. 2010/4/6 AlienBaby > Hi, > > I'm on the hunt for a good quality commercially licensed graphing / > plotting library and wondered if anyone here had any recomendations. > The work to be done is less scientific, more

Re: pass object or use self.object?

2010-04-06 Thread Jean-Michel Pichavant
Tim Arnold wrote: Hi, I have a few classes that manipulate documents. One is really a process that I use a class for just to bundle a bunch of functions together (and to keep my call signatures the same for each of my manipulator classes). So my question is whether it's bad practice to set thing

Re: Recommend Commercial graphing library

2010-04-06 Thread Jean-Michel Pichavant
Pablo Recio Quijano wrote: Why must be commercial, when there is open and free alternatives? Like GNU Plot. Gnuplot is ugly. I'm using it because I don't care if it's ugly but it clearly lacks of look & feel for presentations, as requested by the OP. You have http://matplotlib.sourceforge.ne

Re: per-method jit compiler

2010-04-06 Thread Florian Ludwig
On Mon, 2010-04-05 at 22:45 -0700, Luis M. González wrote: > The above post gave me an idea (very naive, of couse). > What if I write a simple decorator to figure out the types of every > function, and then we use it as a base for a simple method-jit > compiler for python? I think its what done be

Re: pass object or use self.object?

2010-04-06 Thread Xavier Ho
On Wed, Apr 7, 2010 at 1:19 AM, Jean-Michel Pichavant < jeanmic...@sequans.com> wrote: > Usually, when using classes as namespace, functions are declared as static > (or as classmethod if required). > e.g. > > > class Foo: > @classmethod > def process(cls, document): > print 'process of'

Re: Incorrect scope of list comprehension variables

2010-04-06 Thread Lie Ryan
On 04/06/10 18:42, Alain Ketterlin wrote: > Alain Ketterlin writes: > >> d = dict() >> for r in [1,2,3]: >> d[r] = [r for r in [4,5,6]] >> print d > > Thanks to Chris and Paul for the details (the list comp. r actually > leaks). I should have found this by myself. > > My background is more

Python script error when using print

2010-04-06 Thread Robbie
Hi all, So, I'm trying to use Python with an apache2 server to create some web pages. The web server is configured and seems to work correctly, but only with a certain type of script. For instance, this script works fine #!/usr/bin/env python def index(): s = "Hello World" return s But

Re: (a==b) ? 'Yes' : 'No'

2010-04-06 Thread Lie Ryan
On 04/07/10 00:16, Albert van der Horst wrote: > In article , > Peter Otten <__pete...@web.de> wrote: >> Pierre Quentel wrote: >> >>> I'm surprised nobody proposed a solution with itertools ;-) >> >> next(itertools.takewhile(lambda _: a == b, ["yes"]), "no") > > I could learn something here, if y

Re: per-function jit compiler

2010-04-06 Thread Gabriel Genellina
En Tue, 06 Apr 2010 07:23:19 -0300, Luis M. González escribió: On 6 abr, 03:40, Chris Rebert wrote: 2010/4/5 Luis M. González : > This post gave me an idea:http://groups.google.com/group/comp.lang.python/msg/5d75080707104b76 > What if I write a simple decorator to figure out the ty

Re: Recommend Commercial graphing library

2010-04-06 Thread AlienBaby
On Apr 6, 4:24 pm, Jean-Michel Pichavant wrote: > Pablo Recio Quijano wrote: > > Why must be commercial, when there is open and free alternatives? Like > > GNU Plot. > > Gnuplot is ugly. I'm using it because I don't care if it's ugly but it > clearly lacks of look & feel for presentations, as requ

Re: Recommend Commercial graphing library

2010-04-06 Thread Grant Edwards
On 2010-04-06, Jean-Michel Pichavant wrote: > Pablo Recio Quijano wrote: >> Why must be commercial, when there is open and free alternatives? Like >> GNU Plot. > > Gnuplot is ugly. I'm using it because I don't care if it's ugly but it > clearly lacks of look & feel for presentations, as requeste

Re: Recommend Commercial graphing library

2010-04-06 Thread Ed Keith
--- On Tue, 4/6/10, AlienBaby wrote: > From: AlienBaby > Subject: Re: Recommend Commercial graphing library > To: python-list@python.org > Date: Tuesday, April 6, 2010, 12:05 PM > On Apr 6, 4:24 pm, Jean-Michel > Pichavant > wrote: > > Pablo Recio Quijano wrote: > > > Why must be commercial, wh

Re: Recommend Commercial graphing library

2010-04-06 Thread Paul McGuire
On Apr 6, 11:05 am, AlienBaby wrote: > The requirement for a commercial license comes down to being > restricted to not using any open source code. If it's an open source > license it can't be used in our context. You may be misunderstanding this issue, I think you are equating "open source" with

Re: Recommend Commercial graphing library

2010-04-06 Thread Grant Edwards
On 2010-04-06, Grant Edwards wrote: > On 2010-04-06, Jean-Michel Pichavant wrote: >> Pablo Recio Quijano wrote: >>> Why must be commercial, when there is open and free alternatives? Like >>> GNU Plot. >> >> Gnuplot is ugly. I'm using it because I don't care if it's ugly but it >> clearly lacks

Re: Translation docstrings with gettext

2010-04-06 Thread Gabriel Genellina
En Tue, 06 Apr 2010 06:52:57 -0300, sapient escribió: Lie Ryan, thank you for your answer! Why would you want to translate docstring? Docstring is meant for developers not users. I have mentioned that I want to provide API for existing image- processing applicaion in Python. In my case "dev

Re: Recommend Commercial graphing library

2010-04-06 Thread Benjamin Kaplan
On Tue, Apr 6, 2010 at 9:05 AM, AlienBaby wrote: > On Apr 6, 4:24 pm, Jean-Michel Pichavant > wrote: >> Pablo Recio Quijano wrote: >> > Why must be commercial, when there is open and free alternatives? Like >> > GNU Plot. >> >> Gnuplot is ugly. I'm using it because I don't care if it's ugly but i

Re: Incorrect scope of list comprehension variables

2010-04-06 Thread Stephen Hansen
On 2010-04-06 09:34:04 -0700, Lie Ryan said: in python there is only a flat local namespace and the names resolver becomes a thousand times simpler (and faster). This hasn't been true for a long time. Yes, local variables are optimized to be indexed in an array, but Python has nested scopes f

Re: Recommend Commercial graphing library

2010-04-06 Thread Michael Torrie
On 04/06/2010 10:05 AM, AlienBaby wrote: > The requirement for a commercial license comes down to being > restricted to not using any open source code. If it's an open source > license it can't be used in our context. Python itself and all its standard libraries are open source, under the PSF lice

Re: Recommend Commercial graphing library

2010-04-06 Thread superpollo
Grant Edwards ha scritto: On 2010-04-06, Grant Edwards wrote: On 2010-04-06, Jean-Michel Pichavant wrote: Pablo Recio Quijano wrote: Why must be commercial, when there is open and free alternatives? Like GNU Plot. Gnuplot is ugly. I'm using it because I don't care if it's ugly but it clearl

Re: Python script error when using print

2010-04-06 Thread superpollo
Robbie ha scritto: Hi all, So, I'm trying to use Python with an apache2 server to create some web pages. The web server is configured and seems to work correctly, but only with a certain type of script. For instance, this script works fine #!/usr/bin/env python def index(): s = "Hello Wor

Re: (a==b) ? 'Yes' : 'No'

2010-04-06 Thread Duncan Booth
Albert van der Horst wrote: > Old hands would have ... > stamp =( weight>=1000 and 120 or > weight>=500 and 100 or > weight>=250 and 80 or > weight>=100 and 60 or >44 ) > > (Kind of a brain twister, I think, inf

Re: Recommend Commercial graphing library

2010-04-06 Thread Duncan Booth
Grant Edwards wrote: > Seriously, most of the graphs I've seen in "presentations" would make > Ed Tufte spin in his grave. http://flowingdata.com/2010/03/20/powerpoint-and-dying-kittens/ -- http://mail.python.org/mailman/listinfo/python-list

upcoming Python training in Florida, April 27-29

2010-04-06 Thread Mark Lutz
Greetings Python fans, Don't miss your chance to attend our upcoming Florida Python training seminar later this month. This 3-day public class will be held on April 27-29, in Sarasota, Florida. It is open to both individuals and groups. For more details on the class, as well as registration inst

Re: Recommend Commercial graphing library

2010-04-06 Thread AlienBaby
I am just looking at the PSF license now as it goes. It does appear that we should be able to continue using matplotlib. - the restrictions on open-source that have been imposed specifically state it is fine to use the python language, and if matplotlib has the same license I personally can't see a

Re: Is there a standard name for this tree structure?

2010-04-06 Thread egbert
On Sun, Apr 04, 2010 at 12:10:02PM +, Steven D'Aprano wrote: > I can implement this tree using a flat dict: > > root = object() > data = {root: ['Mammal', 'Reptile'], What is the advantage, or thougth behind, using an instance of object as the root of your flat tree ? egbert -- Egbert Bo

Pickle problem while loading a class instance.

2010-04-06 Thread gerardob
Hello, I am new to python and i have a problem using the pickle load function. I have an object m of the class MarkovModel and i want to copy it to a file and load it onto another class: l=[1,2,3] m = markov_model.MarkovModel() m.load_observations(l) file = open("prueba.txt", 'w') pickle.dump(m,f

imports again

2010-04-06 Thread Alex Hall
Sorry this is a forward (long story involving a braille notetaker's bad copy/paste and GMail's annoying mobile site). Basically, I am getting errors when I run the project at http://www.gateway2somewhere.com/sw.zip and I do not understand why. The bad line was working until I added more import stat

Re: pass object or use self.object?

2010-04-06 Thread Lie Ryan
On 04/06/10 23:52, Tim Arnold wrote: > Hi, > I have a few classes that manipulate documents. One is really a > process that I use a class for just to bundle a bunch of functions > together (and to keep my call signatures the same for each of my > manipulator classes). > > So my question is whether

Re: Pickle problem while loading a class instance.

2010-04-06 Thread Peter Otten
gerardob wrote: > Hello, I am new to python and i have a problem using the pickle load > function. > I have an object m of the class MarkovModel and i want to copy it to a > file and load it onto another class: > > l=[1,2,3] > m = markov_model.MarkovModel() > m.load_observations(l) > file = open(

Re: Pickle problem while loading a class instance.

2010-04-06 Thread Lie Ryan
On 04/07/10 03:23, gerardob wrote: > The error below appears. In the case i remove the comment to initialize m2, > the same thing happens. Any ideas on how to fix this? > When unpickling a user-defined class, you unpickling module must have access to the original class definition. This means if

Re: Python script error when using print

2010-04-06 Thread Albert W. Hopkins
On Tue, 2010-04-06 at 08:38 -0700, Robbie wrote: > Hi all, > > So, I'm trying to use Python with an apache2 server to create some web > pages. The web server is configured and seems to work correctly, but > only with a certain type of script. > > For instance, this script works fine > > #!/usr/

Performance of list vs. set equality operations

2010-04-06 Thread Gustavo Narea
Hello! Could you please confirm whether my understanding of equality operations in sets and lists is correct? This is how I think things work, partially based on experimentation and the online documentation for Python: When you compare two lists, *every* element of one of the lists is compared ag

Re: Recommend Commercial graphing library

2010-04-06 Thread Robert Kern
On 2010-04-06 11:44 AM, superpollo wrote: Grant Edwards ha scritto: On 2010-04-06, Grant Edwards wrote: On 2010-04-06, Jean-Michel Pichavant wrote: Pablo Recio Quijano wrote: Why must be commercial, when there is open and free alternatives? Like GNU Plot. Gnuplot is ugly. I'm using it beca

Re: Recommend Commercial graphing library

2010-04-06 Thread Grant Edwards
On 2010-04-06, superpollo wrote: > Grant Edwards ha scritto: >> On 2010-04-06, Grant Edwards wrote: >>> On 2010-04-06, Jean-Michel Pichavant wrote: Pablo Recio Quijano wrote: > Why must be commercial, when there is open and free alternatives? Like > GNU Plot. Gnuplot is ugly.

Re: Performance of list vs. set equality operations

2010-04-06 Thread Chris Colbert
the proof is in the pudding: In [1]: a = range(1) In [2]: s = set(a) In [3]: s2 = set(a) In [5]: b = range(1) In [6]: a == b Out[6]: True In [7]: s == s2 Out[7]: True In [8]: %timeit a == b 1000 loops, best of 3: 204 us per loop In [9]: %timeit s == s2 1 loops, best of 3: 124 us

Re: Recommend Commercial graphing library

2010-04-06 Thread Grant Edwards
On 2010-04-06, Duncan Booth wrote: > Grant Edwards wrote: > >> Seriously, most of the graphs I've seen in "presentations" would make >> Ed Tufte spin in his grave. > > http://flowingdata.com/2010/03/20/powerpoint-and-dying-kittens/ :) Years ago I was walking past a marketing guy's cube, and on

Re: Translation docstrings with gettext

2010-04-06 Thread Lie Ryan
On 04/06/10 19:52, sapient wrote: > Lie Ryan, thank you for your answer! >> Why would you want to translate docstring? Docstring is meant for >> developers not users. > I have mentioned that I want to provide API for existing image- > processing applicaion in Python. > In my case "developers" are "

python as pen and paper substitute

2010-04-06 Thread Manuel Graune
Hello everyone, I am looking for ways to use a python file as a substitute for simple pen and paper calculations. At the moment I mainly use a combination of triple-quoted strings, exec and print (Yes, I know it's not exactly elegant). To clarify, I just start an editor, write a file that might lo

Simplify Python

2010-04-06 Thread ja1lbr3ak
I'm trying to teach myself Python, and so have been simplifying a calculator program that I wrote. The original was 77 lines for the same functionality. Problem is, I've hit a wall. Can anyone help? loop = input("Enter 1 for the calculator, 2 for the Fibonacci sequence, or something else to quit:

Impersonating a Different Logon

2010-04-06 Thread Kevin Holleran
Hello, I am sweeping some of our networks to find devices. When I find a device I try to connect to the registry using _winreg and then query a specific key that I am interested in. This works great for machines that are on our domain, but there are left over machines that are stand alone and th

plotting in python 3

2010-04-06 Thread Rolf Camps
Hi, What's the easiest way to plot graphs in python 3.x? Ís there a package? Quality doesn't really matter. Thanks, Rolf signature.asc Description: Dit berichtdeel is digitaal ondertekend -- http://mail.python.org/mailman/listinfo/python-list

Re: per-method jit compiler

2010-04-06 Thread Irmen de Jong
On 6-4-2010 8:22, Luis M. González wrote: The above post gave me an idea (very naive, of couse). What if I write a simple decorator to figure out the types of every function, and then we use it as a base for a simple method-jit compiler for python? example: def typer(f): def wrap(*args):

Re: plotting in python 3

2010-04-06 Thread Christopher Choi
On Tue, 06 Apr 2010 21:23:34 +0200, Rolf Camps wrote: > Hi, > > What's the easiest way to plot graphs in python 3.x? Ís there a package? > Quality doesn't really matter. > > Thanks, > > Rolf > Hi, > > What's the easiest way to plot graphs in python 3.x? Ís there a package? > Quality doesn't re

Re: Simplify Python

2010-04-06 Thread Christopher Choi
On Tue, 06 Apr 2010 12:04:20 -0700, ja1lbr3ak wrote: > I'm trying to teach myself Python, and so have been simplifying a > calculator program that I wrote. The original was 77 lines for the same > functionality. Problem is, I've hit a wall. Can anyone help? > > loop = input("Enter 1 for the calcu

Re: Impersonating a Different Logon

2010-04-06 Thread Tim Golden
On 06/04/2010 20:26, Kevin Holleran wrote: Hello, I am sweeping some of our networks to find devices. When I find a device I try to connect to the registry using _winreg and then query a specific key that I am interested in. This works great for machines that are on our domain, but there are l

Re: Simplify Python

2010-04-06 Thread ja1lbr3ak
On Apr 6, 4:06 pm, Christopher Choi wrote: > On Tue, 06 Apr 2010 12:04:20 -0700, ja1lbr3ak wrote: > > I'm trying to teach myself Python, and so have been simplifying a > > calculator program that I wrote. The original was 77 lines for the same > > functionality. Problem is, I've hit a wall. Can an

Re: passing command line arguments to executable

2010-04-06 Thread Bror Johansson
On 2010-04-03 18:09, mcanjo wrote: I have an executable (I don't have access to the source code) that processes some data. I double click on the icon and a Command prompt window pops up. The program asks me for the input file, I hit enter, and then it asks me for and output filename, I hit enter

Re: Simplify Python

2010-04-06 Thread Christopher Choi
On Tue, 06 Apr 2010 13:14:44 -0700, ja1lbr3ak wrote: > On Apr 6, 4:06 pm, Christopher Choi wrote: >> On Tue, 06 Apr 2010 12:04:20 -0700, ja1lbr3ak wrote: >> > I'm trying to teach myself Python, and so have been simplifying a >> > calculator program that I wrote. The original was 77 lines for the

Re: python as pen and paper substitute

2010-04-06 Thread Johan Grönqvist
Manuel Graune skrev: To clarify, I just start an editor, write a file that might look something like this: -snip- code=""" a = 1 b = 2 c = 3 result = a + b """ exec(code) print(code) print("result =\t", result) print("result + c =\t", result + c) -snip-- and feed thi

Re: Python script error when using print

2010-04-06 Thread Pierre Quentel
On 6 avr, 20:14, "Albert W. Hopkins" wrote: > On Tue, 2010-04-06 at 08:38 -0700, Robbie wrote: > > Hi all, > > > So, I'm trying to use Python with an apache2 server to create some web > > pages.  The web server is configured and seems to work correctly, but > > only with a certain type of script.

Re: Simplify Python

2010-04-06 Thread ja1lbr3ak
On Apr 6, 4:17 pm, Christopher Choi wrote: > On Tue, 06 Apr 2010 13:14:44 -0700, ja1lbr3ak wrote: > > On Apr 6, 4:06 pm, Christopher Choi wrote: > >> On Tue, 06 Apr 2010 12:04:20 -0700, ja1lbr3ak wrote: > >> > I'm trying to teach myself Python, and so have been simplifying a > >> > calculator pro

Re: plotting in python 3

2010-04-06 Thread Rolf Camps
Op dinsdag 06-04-2010 om 14:55 uur [tijdzone -0500], schreef Christopher Choi: > On Tue, 06 Apr 2010 21:23:34 +0200, Rolf Camps wrote: > > > Hi, > > > > What's the easiest way to plot graphs in python 3.x? Ís there a package? > > Quality doesn't really matter. > > > > Thanks, > > > > Rolf > > H

Re: Simplify Python

2010-04-06 Thread Joaquin Abian
On Apr 6, 9:04 pm, ja1lbr3ak wrote: > I'm trying to teach myself Python, and so have been simplifying a > calculator program that I wrote. The original was 77 lines for the > same functionality. Problem is, I've hit a wall. Can anyone help? > > loop = input("Enter 1 for the calculator, 2 for the F

Re: python as pen and paper substitute

2010-04-06 Thread Manuel Graune
Thanks for your reply. Johan Grönqvist writes: > Manuel Graune skrev: >> To clarify, I just start an editor, write a file that >> might look something like this: >> >> -snip- >> code=""" >> a = 1 >> b = 2 >> c = 3 >> result = a + b >> """ >> exec(code) >> print(code) >> print("result

Re: Simplify Python

2010-04-06 Thread ja1lbr3ak
On Apr 6, 4:56 pm, Joaquin Abian wrote: > On Apr 6, 9:04 pm, ja1lbr3ak wrote: > > > > > > > I'm trying to teach myself Python, and so have been simplifying a > > calculator program that I wrote. The original was 77 lines for the > > same functionality. Problem is, I've hit a wall. Can anyone help

Re: Performance of list vs. set equality operations

2010-04-06 Thread Gustavo Narea
On Apr 6, 7:28 pm, Chris Colbert wrote: > the proof is in the pudding: > > In [1]: a = range(1) > > In [2]: s = set(a) > > In [3]: s2 = set(a) > > In [5]: b = range(1) > > In [6]: a == b > Out[6]: True > > In [7]: s == s2 > Out[7]: True > > In [8]: %timeit a == b > 1000 loops, best of 3: 2

Re: python as pen and paper substitute

2010-04-06 Thread Manuel Graune
Manuel Graune writes: > > The use-case is acually fairly simple. The point is to use a python > source-file as subsitute for scrap-paper (with the opportunity to > edit what is already written and without illegible handwriting). > The output should 1) show manually selected python code and commen

Re: python as pen and paper substitute

2010-04-06 Thread Manuel Graune
Manuel Graune writes: > > The use-case is acually fairly simple. The point is to use a python > source-file as subsitute for scrap-paper (with the opportunity to > edit what is already written and without illegible handwriting). > The output should 1) show manually selected python code and commen

Re: python as pen and paper substitute

2010-04-06 Thread Johan Grönqvist
Manuel Graune skrev: Thanks for your reply. The output should 1) show manually selected python code and comments (whatever I think is important), 2) show selected results (final and intermediate) and 3) *not* show python code that for someone only interested in the calculation and the results

Re: Simplify Python

2010-04-06 Thread Joaquin Abian
On Apr 6, 11:04 pm, ja1lbr3ak wrote: > On Apr 6, 4:56 pm, Joaquin Abian wrote: > > > > > On Apr 6, 9:04 pm, ja1lbr3ak wrote: > > > > I'm trying to teach myself Python, and so have been simplifying a > > > calculator program that I wrote. The original was 77 lines for the > > > same functionality

Re: Performance of list vs. set equality operations

2010-04-06 Thread Chris Colbert
:slaps forehead: good catch. On Tue, Apr 6, 2010 at 5:18 PM, Gustavo Narea wrote: > On Apr 6, 7:28 pm, Chris Colbert wrote: >> the proof is in the pudding: >> >> In [1]: a = range(1) >> >> In [2]: s = set(a) >> >> In [3]: s2 = set(a) >> >> In [5]: b = range(1) >> >> In [6]: a == b >> Ou

Re: python as pen and paper substitute

2010-04-06 Thread Johan Grönqvist
Manuel Graune skrev: Manuel Graune writes: Just as an additional example, let's assume I'd want to add the area of to circles. [...] which can be explained to anyone who knows basic math and is not at all interested in python. Third attempt. The markup now includes tagging of different parts

Re: Simplify Python

2010-04-06 Thread Dave Angel
ja1lbr3ak wrote: I'm trying to teach myself Python, and so have been simplifying a calculator program that I wrote. The original was 77 lines for the same functionality. Problem is, I've hit a wall. Can anyone help? loop = input("Enter 1 for the calculator, 2 for the Fibonacci sequence, or somet

Re: python as pen and paper substitute

2010-04-06 Thread Dave Angel
Johan Gr wrote: Manuel Graune skrev: Thanks for your reply. The output should 1) show manually selected python code and comments (whatever I think is important), 2) show selected results (final and intermediate) and 3) *not* show python code that for someone only interested in the calculati

Re: In disGuiodoise?

2010-04-06 Thread Andreas Waldenburger
On Mon, 05 Apr 2010 22:03:00 +0200 News123 wrote: > Andreas Waldenburger wrote: > > On Mon, 05 Apr 2010 13:48:15 +0200 News123 wrote: > > > >> Martin P. Hellwig wrote: > >>> On 04/05/10 00:05, r wrote: > >>> > However i have also considered that maybe *all* the "well knowns" > are in

Re: python as pen and paper substitute

2010-04-06 Thread Chris Colbert
you may have a look at sage: http://www.sagemath.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Incorrect scope of list comprehension variables

2010-04-06 Thread Gregory Ewing
Lie Ryan wrote: in python there is only a flat local namespace and the names resolver becomes a thousand times simpler No, it doesn't. The compiler already has to deal with multiple scopes for nested functions. There may be some simplification, but not a lot. The main reason is linguistic. Hav

Re: Incorrect scope of list comprehension variables

2010-04-06 Thread Rolando Espinoza La Fuente
On Sun, Apr 4, 2010 at 5:20 PM, Paul Rubin wrote: [...] > >    d[r] = list(r for r in [4,5,6]) > This have a slightly performance difference. I think mainly the generator's next() call. In [1]: %timeit list(r for r in range(1)) 100 loops, best of 3: 2.78 ms per loop In [2]: %timeit [r for r

s-expression parser in python

2010-04-06 Thread James Stroud
Hello All, I want to use an s-expression based configuration file format for a python program I'm writing. Does anyone have a favorite parser? I'm currently using sexpy.parse() (http://pypi.python.org/pypi/sexpy) which works very well but I don't know how secure it is. Does anyone have exper

Re: python as pen and paper substitute

2010-04-06 Thread James Stroud
Manuel Graune wrote: Hello everyone, I am looking for ways to use a python file as a substitute for simple pen and paper calculations. At the moment I mainly use a combination of triple-quoted strings, exec and print (Yes, I know it's not exactly elegant). To clarify, I just start an editor, wri

Re: s-expression parser in python

2010-04-06 Thread Patrick Maupin
On Apr 6, 7:02 pm, James Stroud wrote: I have a parser/emitter I wrote about 4 years ago for EDIF. Take a look at the wikipedia article http://en.wikipedia.org/wiki/EDIF If that is close to you want, I can send it to you. The whole parser/ emitter/XML round-tripper etc. is only 500 lines, whic

Re: python as pen and paper substitute

2010-04-06 Thread Ethan Furman
Manuel Graune wrote: Manuel Graune writes: The use-case is acually fairly simple. The point is to use a python source-file as subsitute for scrap-paper (with the opportunity to edit what is already written and without illegible handwriting). The output should 1) show manually selected python c

Re: s-expression parser in python

2010-04-06 Thread Paul McGuire
On Apr 6, 7:02 pm, James Stroud wrote: > Hello All, > > I want to use an s-expression based configuration file format for a > python program I'm writing. Does anyone have a favorite parser? > The pyparsing wiki includes this parser on its Examples page: http://pyparsing.wikispaces.com/file/view/s

  1   2   >