ANN: 4 little Python programs

2006-05-05 Thread RM
I recently got access to one of those new GooglePages and decided to play around with it a little. I figured it would be a nice *easy* way to get a website going. I may eventually do something more professional, but hey, this was free in both money and time. :) I had been thinking of releasing

Leipzig Python User Group - Meeting, May 9 2006, 8:00pm

2006-05-05 Thread Mike Mueller
= Leipzig Python User Group = Next Meeting Tuesday, May 9 2006 --- We will meet on April 9 at 8:00 pm at the training center of Python Academy in Leipzig, Germany (http://www.python-academy.com/center/find.html).

Re: Can I use python for this .. ??

2006-05-05 Thread Terry Reedy
placid [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] .) When you hibernate/boot up/hibernate for a long time without a clean reboot, Windows becomes unstable... This seems to depend on the system. I have gone at least a week, maybe two, with nightly hibernations and no

Re: Possible constant assignment operators := and ::= for Python

2006-05-05 Thread Michele Simionato
Edward Elliott wrote: Michele Simionato wrote: A = [] # let's declare a constant here b = A # and let's assign the constant here b.append('1') # OOPS! But it makes no sense to use a mutable object for a constant! The user should use a tuple, Sure. Now show me the builtin

Re: Tuple assignment and generators?

2006-05-05 Thread Michele Simionato
Carl Banks wrote: q = 0 r = 0 s = 0 id(q) 134536636 id(r) 134536636 id(s) 134536636 It is okay with constant object, really. No: r=11 s=11 t=11 id(r) 135620508 id(s) 135620532 id(t) 135104688 It worked with the number 0 because of an implementation accident,

Embedding Python: How to run compiled(*.pyc/*.pyo) files using Python C API?

2006-05-05 Thread Shankar
Hello, I am trying to run compiled Python files (*.pyc and *.pyo) using Python C API. I am using the method PyRun_FileFlags() for this purpose. The code snippet is as follows:- PyCompilerFlags myFlags; myFlags.cf_flags=1; // I tried all values 0, 1 and 2 PyRun_FileFlags(script, file,

Job opportunity in France

2006-05-05 Thread Rony Steelandt
We have a vacancy for a python programmer for a 6 months assignement. If interested, please visit www.bucodi.com And don't worry we speak english :) R_ -- --- Rony Steelandt BuCodi rony dot steelandt (at) bucodi dot com Visit the python blog at http://360.yahoo.com/bucodi --

Re: Tuple assignment and generators?

2006-05-05 Thread vdrab
Wow, so, to see if I understand correctly: r = 0 s = 0 t = 11 u = 11 r == s True t == u True r is s True t is u False ... ? what the...? does anybody else get mighty uncomfortable about this? s. -- http://mail.python.org/mailman/listinfo/python-list

Re: Tuple assignment and generators?

2006-05-05 Thread Erik Max Francis
vdrab wrote: what the...? does anybody else get mighty uncomfortable about this? No. Why should you ever care about whether two integers representing values are the same object? Your tests should be with `==`, not `is`. -- Erik Max Francis [EMAIL PROTECTED] http://www.alcyone.com/max/

Re: __init__.py, __path__ and packaging

2006-05-05 Thread Sandro Dentella
Now, why you couldn't do dbg.DBG = ...? Very simple... from module import * doesn't give you a dbg /module/, it only gives you references to each piece inside the module. really the reason why I wanted that should probably be solved in other ways. I just wanted to split my dbg module

Re: Job opportunity in France

2006-05-05 Thread Alexandre Fayolle
Le 05-05-2006, Rony [EMAIL PROTECTED] nous disait: We have a vacancy for a python programmer for a 6 months assignement. Hi Rony, You may find interested people on fr.comp.lang.python and on the python-fr mailing list (python at aful dot org), if you post your announce (in French) on these

Re: Python for Perl programmers

2006-05-05 Thread Christoph Haas
On Thu, May 04, 2006 at 12:02:52PM -0400, A.M wrote: Is there any efficient online resource or book that help experienced Perl programmers to Python? I've been using Perl for a decade and had a hard start into Python. Mainly because I used those phrasebooks and tried to convert my Perl syntax

Re: Embedding Python: How to run compiled(*.pyc/*.pyo) files using Python C API?

2006-05-05 Thread Serge Orlov
Shankar wrote: Hello, I am trying to run compiled Python files (*.pyc and *.pyo) using Python C API. I am using the method PyRun_FileFlags() for this purpose. The code snippet is as follows:- PyCompilerFlags myFlags; myFlags.cf_flags=1; // I tried all values 0, 1 and 2

Re: Tuple assignment and generators?

2006-05-05 Thread Diez B. Roggisch
vdrab wrote: Wow, so, to see if I understand correctly: r = 0 s = 0 t = 11 u = 11 r == s True t == u True r is s True t is u False ... ? what the...? does anybody else get mighty uncomfortable about this? #include stdio.h int main(int argc, char **argv) { int a =

Re: Python for Perl programmers

2006-05-05 Thread bruno at modulix
A.M wrote: Hi, Is there any efficient online resource or book that help experienced Perl programmers to Python? My fellow coworker - experimented Perl coder - confirms that the official tutorial and diveintopython should be enough to get you started. Also, the Python Cookbook and reading

enriching return values / symetric callreturn in P3K ? - Re: Tuple assignment and generators?

2006-05-05 Thread robert
Tim Chase wrote: Just as a pedantic exercise to try and understand Python a bit better, I decided to try to make a generator or class that would allow me to unpack an arbitrary number of calculatible values. In this case, just zeros (though I just to prove whatever ends up working, having

Re: Tuple assignment and generators?

2006-05-05 Thread vdrab
No. Why should you ever care about whether two integers representing values are the same object? Your tests should be with `==`, not `is`. Given this though, what other such beauties are lurking in the interpreter, under the name of 'implementation accidents'? One of the things that drew me

Re: noob question: TypeError wrong number of args

2006-05-05 Thread bruno at modulix
Edward Elliott wrote: bruno at modulix wrote: Edward Elliott wrote: Ah, well then, there's no need for a full-blown parser. It should suffice to recognize a class definition and modify the parameter list of every def indented one level further than that. won't do : class

Re: Strange Threads Behaviour...

2006-05-05 Thread rodmc
Hi Diez, No this occurs when the client is executed. Basically it runs as you see above then terminates. It should be noted that the errors involving the /xmpp libraries seem to change each time. I have no doubt it is connected to that, but the error does not happen at all when I run the client

Re: Tuple assignment and generators?

2006-05-05 Thread vdrab
beasts. It can get even worse: I can define an object (in C++ as well as in python) that is not even equal to itself. Not that I felt the need for that so far hehe... now you've picked my curiosity... how? ps. def __eq__(self, other): return False does not count ! --

Re: Possible constant assignment operators := and ::= for Python

2006-05-05 Thread Fredrik Lundh
Christophe wrote: I think you've made a mistake in your example. constant A = [] def foo(var): ... var.append('1') ... print var ... b = A foo(b) foo(b) and this ? constant A = [] print A is A Obviously, False. why

Re: Tuple assignment and generators?

2006-05-05 Thread Diez B. Roggisch
vdrab wrote: beasts. It can get even worse: I can define an object (in C++ as well as in python) that is not even equal to itself. Not that I felt the need for that so far hehe... now you've picked my curiosity... how? ps. def __eq__(self, other): return False does not count !

Re: Tuple assignment and generators?

2006-05-05 Thread Fredrik Lundh
vdrab wrote: Given this though, what other such beauties are lurking in the interpreter, under the name of 'implementation accidents'? One of the things that drew me to python is the claimed consistency and orthogonality of both language and implementation, not sacrificing clarity for

SIGTERM handling

2006-05-05 Thread Manlio Perillo
Hi. I have tried this script: from ctypes import cdll, c_int from signal import SIGTERM, SIGINT from time import sleep msvcrt = cdll.LoadLibrary(MSVCR71) # is this the lib to use? sig = c_int(SIGTERM) raise_ = getattr(msvcrt, raise) raise_(sig) sleep(10) The problem is that SIGTERM causes

Re: Tuple assignment and generators?

2006-05-05 Thread Diez B. Roggisch
vdrab wrote: No. Why should you ever care about whether two integers representing values are the same object? Your tests should be with `==`, not `is`. Given this though, what other such beauties are lurking in the interpreter, under the name of 'implementation accidents'? One of the

ISSPR2006_School_etc.:NEW_EXTENDED_Deadline

2006-05-05 Thread andrea
REGISTER NOW FOR PATTERN RECOGNITION EVENTS THIS SUMMER, 2006 ___ 4TH INTERNATIONAL SUMMER SCHOOL ON PATTERN RECOGNITION (ISSPR, 2006) 23-28 JULY, UK http://www.PatternRecognitionSchool.com NEW...EXTENDED Early Bird Deadline for Registration. New Deadline 25th May 2006!

Re: Can I use python for this .. ??

2006-05-05 Thread san
Rick Thanks for your reply .. didnt quite get your point in loggin into password protected site. Will try to seach this group for more .. Still looking for tab browsing and logging in password protected site .. can i use ctype or something like that .. some modute that will introduce key

Re: Tuple assignment and generators?

2006-05-05 Thread vdrab
so anything you don't understand, and cannot be bothered to look up in the documentation, just has to be an inconsistent ad-hoc weird-gotcha design ? Does the documentation mention that x is y returns True when they are both 0 but not when they are 11 ? If so, I stand corrected. *plonk*

Re: Tuple assignment and generators?

2006-05-05 Thread Daniel Nogradi
Given this though, what other such beauties are lurking in the interpreter, under the name of 'implementation accidents'? One of the things that drew me to python is the claimed consistency and orthogonality of both language and implementation, not sacrificing clarity for performance,

Re: Tuple assignment and generators?

2006-05-05 Thread Alexandre Fayolle
Le 05-05-2006, Diez [EMAIL PROTECTED] nous disait: The thing you observe as accident is that sometimes 0 is 0 is true just because of an optimization of number objects allocation. Such things happen in the real world - other examples are string-interning in e.g. the JVM (and I bet they have a

Re: Tuple assignment and generators?

2006-05-05 Thread Fredrik Lundh
vdrab wrote: Does the documentation mention that x is y returns True when they are both 0 but not when they are 11 ? language reference, comparisions (is operator): The operators is and is not test for object identity: x is y is true if and only if x and y are the same object

Re: Tuple assignment and generators?

2006-05-05 Thread Diez B. Roggisch
I was just at a point when I thought I learned something but got confused again after trying the following and unfortunately didn't find an answer in the docs. a = 10 b = 10 id(a) 134536516 id(b) 134536516 So the two memory addesses are the same, but a = 1 b = 1 id(a)

Re: Tuple assignment and generators?

2006-05-05 Thread Daniel Nogradi
I was just at a point when I thought I learned something but got confused again after trying the following and unfortunately didn't find an answer in the docs. a = 10 b = 10 id(a) 134536516 id(b) 134536516 So the two memory addesses are the same, but a = 1 b =

Re: Tuple assignment and generators?

2006-05-05 Thread vdrab
language reference, objects: Even the importance of object identity is affected in some sense: for immutable types, operations that compute new values may actually return a reference to any existing object with the same type and value, while for mutable objects this is not

Re: Subclassing array

2006-05-05 Thread TG
That's great, thanks ! To put it short, when I create a Stimulus object, it first seek __new__() method. But if I don't define it, it looks for the one defined in Vector. This raises a problem because the parameters passed to Stimulus(params) aren't fitting with Vector parameters, raising an

Is this a good use of __metaclass__?

2006-05-05 Thread Joel Hedlund
Hi! I need some input on my use of metaclasses since I'm not sure I'm using them in a pythonic and graceful manner. I'm very grateful for any tips, pointers and RTFMs I can get from you guys. Below, you'll find some background info and an executable code example. In the code example I have

unittest.main-workalike that runs doctests too?

2006-05-05 Thread John J. Lee
...I wrote something to do this once, but didn't do as good a job as I might have done and wondered if anybody else has done it properly. I know about nose, but it seems just a little too magical for my tastes, and includes stuff I don't really need. John --

Re: Tuple assignment and generators?

2006-05-05 Thread Diez B. Roggisch
vdrab wrote: That, I knew. What I did not know, nor get from this explanation, is that this behaviour may differ not only within the same implementation, but with instances of the same class or type (in this case, 'int'). E.g., after a = 1; b = 1,     a and b may or may not refer to the

Re: Tuple assignment and generators?

2006-05-05 Thread Duncan Booth
Daniel Nogradi wrote: a = 10 b = 10 id(a) 134536516 id(b) 134536516 So the two memory addesses are the same, but a = 1 b = 1 id(a) 134604216 id(b) 134604252 and they are not the same (I restarted the interpreter between the two cases). So how is this now? Sorry if

Re: Tuple assignment and generators?

2006-05-05 Thread vdrab
E.g., after a = 1; b = 1, a and b may or may not refer to the same object with the value one, depending on the implementation, But when in a specific implementation this property _does_ hold for ints having value 1, I expect the same behaviour for ints with other values than 1. I

Re: CRC calculation

2006-05-05 Thread Raymond L. Buvel
[EMAIL PROTECTED] wrote: Does anyone know where I can get python code to perform a CRC calculation on an IP packet? Check out http://crcmod.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Subclassing array

2006-05-05 Thread bruno at modulix
TG wrote: That's great, thanks ! To put it short, when I create a Stimulus object, it first seek __new__() method. But if I don't define it, it looks for the one defined in Vector. This raises a problem because the parameters passed to Stimulus(params) aren't fitting with Vector parameters,

Re: Swaying A Coder Away From Python

2006-05-05 Thread A.M. Kuchling
On Thu, 4 May 2006 13:08:52 +0200, Fredrik Lundh [EMAIL PROTECTED] wrote: who's this, and why does he think that sampling some random comments by some random bloggers should mean anything to anyone ? (and why do you seem to think that this matters, btw ?) Michal Wallace, the original

ANN: Crunchy Frog 0.2.5

2006-05-05 Thread André
Crunchy Frog is a desktop web application that transforms a traditional Python web-based tutorial into an interactive session within a browser. At present it is limited to tutorials (html files) that are contained within a single directory on the computer where it is run. You can download from

Re: Tuple assignment and generators?

2006-05-05 Thread Paul Boddie
Tim Chase wrote: I was hoping that there was just some __foo__ property I was missing that would have been called in the process of tuple unpacking that would allow for a more elegant solution such as a generator (or generator method on some object) rather than stooping to disassembling

(question) How to use python get access to google search without query quota limit

2006-05-05 Thread Per
I am doing a Natural Language processing project for academic use, I think google's rich retrieval information and query-segment might be of help, I downloaded google api, but there is query limit(1000/day), How can I write python code to simulate the browser-like-activity to submit more than 10k

Re: Tuple assignment and generators?

2006-05-05 Thread Boris Borcic
vdrab wrote: E.g., after a = 1; b = 1, a and b may or may not refer to the same object with the value one, depending on the implementation, But when in a specific implementation this property _does_ hold for ints having value 1, I expect the same behaviour for ints with other

Re: (question) How to use python get access to google search without query quota limit

2006-05-05 Thread Heiko Wundram
Am Freitag 05 Mai 2006 13:37 schrieb Per: I think google's rich retrieval information and query-segment might be of help, I downloaded google api, but there is query limit(1000/day), How can I write python code to simulate the browser-like-activity to submit more than 10k queries in one day?

Re: unittest.main-workalike that runs doctests too?

2006-05-05 Thread Jay Parlar
On May 5, 2006, at 6:35 AM, John J. Lee wrote: ...I wrote something to do this once, but didn't do as good a job as I might have done and wondered if anybody else has done it properly. I know about nose, but it seems just a little too magical for my tastes, and includes stuff I don't really

Re: (question) How to use python get access to google search without query quota limit

2006-05-05 Thread Duncan Booth
Heiko Wundram wrote: Am Freitag 05 Mai 2006 13:37 schrieb Per: I think google's rich retrieval information and query-segment might be of help, I downloaded google api, but there is query limit(1000/day), How can I write python code to simulate the browser-like-activity to submit more than

Re: (question) How to use python get access to google search without query quota limit

2006-05-05 Thread Per
Yeah, Thanks Am, I can be considered as an advanced google user, presumably.. But I am not a advanced programmer yet. If everyone can generate unlimited number of queries, soon the user-query-data, which I believe is google's most advantage, will be in chaos. Can they simply ignore some queries

Re: Can I use python for this .. ??

2006-05-05 Thread nikie
san wrote: Hi I am using windows xp and have installed python and win32. I am familiar with basic Python. I wanted to control some of the applications via python script. I would like to write a python script to say: 1. Open firefox and log on to gmail 2. Another firefox window to visit

Re: ConfigParser and multiple option names

2006-05-05 Thread [EMAIL PROTECTED]
that will break horribly in windows, remenber it install all it's crap in c:\Program Files -- http://mail.python.org/mailman/listinfo/python-list

Re: Tuple assignment and generators?

2006-05-05 Thread vdrab
Are you telling us that you *had* read that doc, and tripped because it says depending on the implementation, when it should say at the choice of the implementation ? no. let's see, where to start ... ? let's say there's a certain property P, for the sake of this lng discussion, something

Method acting on arguements passed

2006-05-05 Thread Panos Laganakos
I want a class method to take action depending on the type of the arguement passed to it. ie: getBook(id) # get the book by ID getBook(name) # get the book by name ... Other languages use the term function/method overloading to cope with this. And when I googled about it seems that GvR is

Re: Tuple assignment and generators?

2006-05-05 Thread Diez B. Roggisch
vdrab wrote: E.g., after a = 1; b = 1, a and b may or may not refer to the same object with the value one, depending on the implementation, But when in a specific implementation this property _does_ hold for ints having value 1, I expect the same behaviour for ints with other

Re: String Exceptions (PEP 352)

2006-05-05 Thread bruno at modulix
Paul Rubin wrote: bruno at modulix [EMAIL PROTECTED] writes: What's wrong with: assert foo and bar and i 10, \ if foo and bar i must not be greater than 10 It doesn't necessarily do anything. With optimization enable, assert is a no-op. quoting the OP (emphasis is mine): I use

Re: Python for Perl programmers

2006-05-05 Thread Thomas Guettler
Am Thu, 04 May 2006 12:02:52 -0400 schrieb A.M: Hi, Is there any efficient online resource or book that help experienced Perl programmers to Python? You can try the examples of pleac: http://pleac.sourceforge.net/pleac_python/index.html This is the Per Cookbook translated into

Active Directory Authentication

2006-05-05 Thread D
Is it possible to have Python authenticate with Active Directory? Specifically what I'd like to do is have a user enter a username/password, then have Python check the credentials with AD - if what they entered is valid, for example, it returns a 1, otherwise a 0.. Thanks! --

Re: regex to exctract informations

2006-05-05 Thread Colin Gillespie
Bob wrote: Dears, I am trying to search and replace strings with regex. The string is identified by a keyword : IDImage(1M234567); DescriptionImage(Desc of the Image 1); I want to exctract the IDImage (1M234567 ) and the Description. The ID are characters and numbers, the

Re: Method acting on arguements passed

2006-05-05 Thread Diez B. Roggisch
Panos Laganakos wrote: I want a class method to take action depending on the type of the arguement passed to it. ie: getBook(id) # get the book by ID getBook(name) # get the book by name ... Other languages use the term function/method overloading to cope with this. And when I googled

Re: Progamming python without a keyboard

2006-05-05 Thread Eric S. Johansson
Rony Steelandt wrote: http://www.newscientisttech.com/article/dn9066 To nice to be true ? its early technology. It's difficult to install and it definitely need some extra horsepower because the two people developing it are also disabled (like me). The only thing I've done to support the

Re: Multiple Version Install?

2006-05-05 Thread David C.Ullrich
On Thu, 4 May 2006 13:19:46 -0400, Tim Peters [EMAIL PROTECTED] wrote: [David C.Ullrich] Would there be issues (registry settings, environment variables, whatever) if a person tried to install versions 1.x and 2.x simultaneously on one Windows system? Windows 98, if it matters. (I can

Re: Method acting on arguements passed

2006-05-05 Thread Duncan Booth
Panos Laganakos wrote: I want a class method to take action depending on the type of the arguement passed to it. ie: getBook(id) # get the book by ID getBook(name) # get the book by name ... Other languages use the term function/method overloading to cope with this. And when I googled

Re: Method acting on arguements passed

2006-05-05 Thread bruno at modulix
Panos Laganakos wrote: I want a class method to take action depending on the type of the arguement passed to it. ie: getBook(id) # get the book by ID getBook(name) # get the book by name ... Other languages use the term function/method overloading to cope with this. And when I googled

ANN: 4 little Python programs

2006-05-05 Thread RM
I recently got access to one of those new GooglePages and decided to play around with it a little. I figured it would be a nice *easy* way to get a website going. I may eventually do something more professional, but hey, this was free in both money and time. :) I had been thinking of releasing

Re: Can I use python for this .. ??

2006-05-05 Thread Doug Bromley
Careful of using the wrong tool for the job. Don't use Python for the sake of it unless its as a learning experience.All of the things you ask for can be done by simply using the Windows start menu to launch a shortcut with various command line options. Voila - problem solved. On 5 May 2006

Re: Active Directory Authentication

2006-05-05 Thread Christoph Haas
On Fri, May 05, 2006 at 05:39:08AM -0700, D wrote: Is it possible to have Python authenticate with Active Directory? Specifically what I'd like to do is have a user enter a username/password, then have Python check the credentials with AD - if what they entered is valid, for example, it

Tkinter Canvas Pre-Buffer

2006-05-05 Thread [EMAIL PROTECTED]
Is there a way that using Tkinter I can pre-render the canvas then draw it on the screen? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Active Directory Authentication

2006-05-05 Thread Stephan Diehl
On Fri, 05 May 2006 05:39:08 -0700, D wrote: Is it possible to have Python authenticate with Active Directory? Specifically what I'd like to do is have a user enter a username/password, then have Python check the credentials with AD - if what they entered is valid, for example, it returns a

Re: cross platform libraries

2006-05-05 Thread diffuser78
Hi Ravi, Do you have any idea how to perform such triigers ? Every help is appreciated. Ravi Teja wrote: No! That's not the way things work. Such code needs to run locally (in this case, Windows). You can run this program as a daemon on Windows with some nice simple remote interface (Eg:

Re: Method acting on arguements passed

2006-05-05 Thread Andrew Gwozdziewycz
I want a class method to take action depending on the type of the arguement passed to it. ie: getBook(id) # get the book by ID getBook(name) # get the book by name Keyword arguments are going to be the best solution, but you'll still have to do checks like in this example which uses a

how to remove 50000 elements from a 100000 list?

2006-05-05 Thread Ju Hui
I want to remove about 5 elements from a list,which has 10 elements. sample code like below: a=range(10) b=range(4) for x in b: ... a.remove(x) ... a [4, 5, 6, 7, 8, 9] when a and b is small size, it will finished quickly, but when a and b have many elements. such as:

PUDGE - Colored Code Blocks / Mailing List Access

2006-05-05 Thread lazaridis_com
Colored Code Blocks Pudge generated documentation can contain colored code blocks, using the rst directive ..code-block:: Python (an other languages supported by SilverCity). http://pudge.lesscode.org/trac/ticket/21 http://pudge.lesscode.org/trac/changeset/126 - Mailing List The Pudge

Is this a legal / acceptable statement ?

2006-05-05 Thread Philippe Martin
Hi, This code works, but is it appropriate ? l_init = False if True == l_init and 1234 = l_value: print 'l_value is initialized' I know I can do this with a try but ... Philippe -- http://mail.python.org/mailman/listinfo/python-list

PUDGE - Colored Code Blocks / Mailing List Access

2006-05-05 Thread lazaridis_com
Colored Code Blocks Pudge generated documentation can contain colored code blocks, using the rst directive ..code-block:: Python (an other languages supported by SilverCity). http://pudge.lesscode.org/trac/ticket/21 http://pudge.lesscode.org/trac/changeset/126 - Mailing List The Pudge

Re: Tkinter Canvas Pre-Buffer

2006-05-05 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: Is there a way that using Tkinter I can pre-render the canvas then draw it on the screen? not really; the canvas is double-buffered, but it regenerates (portions of) the buffer when necessary. if you want to draw in a separate buffer, and use that when updating the

Re: cross platform libraries

2006-05-05 Thread diffuser78
I went to this webpage http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/360649 Isn't it supposed to run on the network and close the connected machine. Every help is appreciate, Dennis Lee Bieber wrote: On 4 May 2006 09:57:15 -0700, [EMAIL PROTECTED] declaimed the following in

Re: how to remove 50000 elements from a 100000 list?

2006-05-05 Thread Diez B. Roggisch
Ju Hui wrote: I want to remove about 5 elements from a list,which has 10 elements. sample code like below: a=range(10) b=range(4) for x in b: ... a.remove(x) ... a [4, 5, 6, 7, 8, 9] when a and b is small size, it will finished quickly, but when a and b have many

Re: Tuple assignment and generators?

2006-05-05 Thread Sion Arrowsmith
vdrab [EMAIL PROTECTED] wrote: let's say there's a certain property P, for the sake of this lng discussion, something more or less like a class or type's property of having immutable values, such that any instance with value X has a single, unique representation in memory and any two

Re: how to remove 50000 elements from a 100000 list?

2006-05-05 Thread [EMAIL PROTECTED]
Try to use set objects: a=set(range(10)) b=set(range(5)) a = a - b -- http://mail.python.org/mailman/listinfo/python-list

Re: how to remove 50000 elements from a 100000 list?

2006-05-05 Thread Tim Chase
but when a and b have many elements. such as: a=range(10) b=range(5) for x in b: ... a.remove(x) ... it will very slowly. Well, your problem is rather ambiguous. In your examples, you're removing contiguous ranges. Thus, you should be able to do something like a =

Re: how to remove 50000 elements from a 100000 list?

2006-05-05 Thread Jack Orenstein
On May 5, 2006, at 9:36 AM, Ju Hui wrote: a=range(10) b=range(5) for x in b: ... a.remove(x) ... it will very slowly. Shall I change to another data structure and choos a better arithmetic? any suggestion is welcome. If removal is an O(n) operation, then removing 1/2

Re: Is this a legal / acceptable statement ?

2006-05-05 Thread vbgunz
you don't have to say: if True == l_init it is suggested you simply say: if l_init: Remember the and operator requires expressions on both sides to be true to continue. If you notice, your expression on the right side of the 'and' is an assignment and so this is forbidden (SyntaxError).

Re: Python for Perl programmers

2006-05-05 Thread Alex Martelli
John J. Lee [EMAIL PROTECTED] wrote: A.M [EMAIL PROTECTED] writes: Is there any efficient online resource or book that help experienced Perl programmers to Python? Worry instead about how you're going to keep maintaining your Perl code after you've developed an allergic response to it.

Re: how to remove 50000 elements from a 100000 list?

2006-05-05 Thread Larry Bates
Ju Hui wrote: I want to remove about 5 elements from a list,which has 10 elements. sample code like below: a=range(10) b=range(4) for x in b: ... a.remove(x) ... a [4, 5, 6, 7, 8, 9] when a and b is small size, it will finished quickly, but when a and b have many

Re: how to remove 50000 elements from a 100000 list?

2006-05-05 Thread Diez B. Roggisch
How about a listcomprehension? new_list = [e for e in old_list if predicate(e)] # Possibly you need this, too: old_list[:] = new_list forgot the predicate. And you should use a set of objects to remove, as then you'd have O(1) behavior for the in-operator So: to_remove = set(b)

Re: Is this a legal / acceptable statement ?

2006-05-05 Thread Philippe Martin
I'm sorry (typo): l_init = False if True == l_init and 1234 == l_value: print 'l_value is initialized' Note that 1234 == l_value does not get evaluated. Philippe vbgunz wrote: you don't have to say: if True == l_init it is suggested you simply say: if l_init: Remember the

Re: Is this a legal / acceptable statement ?

2006-05-05 Thread Larry Bates
Philippe Martin wrote: Hi, This code works, but is it appropriate ? l_init = False if True == l_init and 1234 = l_value: print 'l_value is initialized' I know I can do this with a try but ... Philippe 1) You have a syntax error 1234 == l_value (note ==) 2) This doesn't test

Re: Tuple assignment and generators?

2006-05-05 Thread vdrab
oh wow... it gets better... x = test! y = test! x is y False x = test y = test x is y True ... I had no clue. I guess the take-away lesson is to steer clear from any reliance on object identity checks, if at all possible. Are there any other such optimizations one should like to know

Re: cross platform libraries

2006-05-05 Thread Max Erickson
[EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: I went to this webpage http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/360649 Isn't it supposed to run on the network and close the connected machine. That code uses the windows libraries on the machine it is run on to generate

Re: Tuple assignment and generators?

2006-05-05 Thread Dave Hansen
On 5 May 2006 05:23:24 -0700 in comp.lang.python, vdrab [EMAIL PROTECTED] wrote: Are you telling us that you *had* read that doc, and tripped because it says depending on the implementation, when it should say at the choice of the implementation ? no. let's see, where to start ... ? let's say

Re: Is this a legal / acceptable statement ?

2006-05-05 Thread Philippe Martin
Larry Bates wrote: Philippe Martin wrote: Hi, This code works, but is it appropriate ? l_init = False if True == l_init and 1234 = l_value: print 'l_value is initialized' I know I can do this with a try but ... Philippe 1) You have a syntax error 1234 == l_value (note

Re: Tuple assignment and generators?

2006-05-05 Thread Fredrik Lundh
vdrab wrote: I guess the take-away lesson is to steer clear from any reliance on object identity checks, if at all possible. Are there any other such optimizations one should like to know about? so in your little world, an optimization that speeds things up and saves memory isn't really an

Re: Is this a legal / acceptable statement ?

2006-05-05 Thread bruno at modulix
Philippe Martin wrote: Hi, This code works, but is it appropriate ? appropriate for what ?-) l_init = False # corrected typo, cf other post in this thread if True == l_init and 1234 == l_value: print 'l_value is initialized' Do this in production code, and have one of the first Python

Re: Tuple assignment and generators?

2006-05-05 Thread Diez B. Roggisch
... I had no clue. We figured that I guess the take-away lesson is to steer clear from any reliance on object identity checks, if at all possible. You've been told that quite a few times before that is is not intended for what you used it. Some people actually listen to what others

Re: how to remove 50000 elements from a 100000 list?

2006-05-05 Thread Sion Arrowsmith
Tim Chase [EMAIL PROTECTED] wrote: Another attempt might be to try a = [x for x in a if x not in b] However, this is still doing A*B checks, and will likely degrade with as their sizes increase. Combine this with the use of sets others have suggested if the order of a matters, ie: bset =

Re: Is this a legal / acceptable statement ?

2006-05-05 Thread bruno at modulix
Philippe Martin wrote: (snip) l_init really is a boolean parameter and l_value a value that _might_ exist in a shelve. So I just want to have a parameter to a method so if the first value tested is false (l_init) then the second (l_value) does not get tested ... because it is the second

Re: Is this a legal / acceptable statement ?

2006-05-05 Thread Fredrik Lundh
Philippe Martin wrote: l_init really is a boolean parameter and l_value a value that _might_ exist in a shelve. So I just want to have a parameter to a method so if the first value tested is false (l_init) then the second (l_value) does not get tested ... because it is the second in the

Re: cross platform libraries

2006-05-05 Thread diffuser78
Can we have some program in Linux which shuts down the windows computer remotely. Every help is appreciated. Max Erickson wrote: [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: I went to this webpage http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/360649 Isn't it

  1   2   3   >