Re: Jargons of Info Tech industry

2005-08-23 Thread l v
Xah Lee wrote: > (circa 1996), and email should be text only (anti-MIME, circa 1995), I think e-mail should be text only. I have both my email and news readers set to display in plain text only. It prevents the marketeers and spammers from obtaining feedback that my email address is valid. A

Re: Jargons of Info Tech industry

2005-08-23 Thread l v
Mike Schilling wrote: > "l v" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Xah Lee wrote: >> >>>(circa 1996), and email should be text only (anti-MIME, circa 1995), >> >>I think e-mail should be text only. I have

Re: aproximate a number

2005-08-29 Thread Devan L
Thomas Bartkus wrote: > On Sun, 28 Aug 2005 23:11:09 +0200, billiejoex wrote: > > > Hi all. I'd need to aproximate a given float number into the next (int) > > bigger one. Because of my bad english I try to explain it with some example: > > > > 5.7 --> 6 > > 52.987 --> 53 > > 3.34 --> 4 > > 2.1 -->

Re: aproximate a number

2005-08-29 Thread Devan L
Grant Edwards wrote: > On 2005-08-30, Devan L <[EMAIL PROTECTED]> wrote: > > > > RoundToInt(2.0) will give you 3. > > That's what the OP said he wanted. The next bigger integer > after 2.0 is 3. > > -- > Grant Edwards

Re: Adding bound methods dynamically... CORRECTED

2005-08-30 Thread Devan L
Kevin Little wrote: > I want to dynamically add or replace bound methods in a class. I want > the modifications to be immediately effective across all instances, > whether created before or after the class was modified. I need this > to work for both old ('classic') and new style classes, at both

Re: 'isa' keyword

2005-09-03 Thread Devan L
talin at acm dot org wrote: > Thanks for all the respones :) I realized up front that this suggestion > is unlikely to gain approval, for reasons eloquently stated above. > However, there are still some interesting issues raised that I would > like to discuss. > > Let me first respond to a few of t

Re: python logo

2005-09-03 Thread Devan L
Xah Lee wrote: > what's the decision? any reference to the discussion? > > i thought it is better for Python to have one single recognizable logo. > Perhaps python doesn't have a logo and the official python people > decided it shouldn't or just doesn't have one currently? > > of course, a logo he

Re: Python compiled?

2005-09-05 Thread Devan L
billiejoex wrote: > Hi all. I'm sorry for a noob question like this but I'll try to ask it > anyway. > One of the greatest problem that may discourage a new user to choose Python > language is it's interpreted nature. What? The instant gratification of immediate results is not discouraging. > Ano

Re: infinite loop

2005-09-06 Thread Devan L
LOPEZ GARCIA DE LOMANA, ADRIAN wrote: > Hi all, > > I have a question with some code I'm writting: > > > def main(): > > if option == 1: > > function_a() > > elif option == 2: > > function_b() > > else: > > raise 'option has to be either 1 or 2' > > if itera

Re: Newbie - instanciating classes from other files

2005-09-14 Thread Devan L
[EMAIL PROTECTED] wrote: > Hey guys, i just started learning python (i usually use java/C). > > this has got me stumped as its not mentioned in the documentation > (unless im skimming it every time). > > How does one instanciate a class from another file import somefile foo = somefile.class(__ini

help for conversion of NUMARRAY to PIL object

2005-09-15 Thread A. L.
hi, everybody here, I am a newbie to python. I encounter a problem that how to convert an array of numarray to pil object. For example, the data in an image is extracted using Image.getdata, then the data are converted into an array in numarray. But when the array is needed to convert to the

Re: help for conversion of NUMARRAY to PIL object

2005-09-15 Thread A. L.
Thanks. But some problems remain. I have known using Image.tostring/fromstring and numarray.tostring/fromstring can do the job. But when confronting multi-spectral images, e.g., RGB color images, I don't know how to do it. Could you give some advices on that? You wrote "In [14]: img = Image.fromb

How to clear screen in Python interactive shell mode?

2005-09-15 Thread A. L.
In Python interactive mode, is there some function acting like 'clear' command in bash? Could somebody here give some advice? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list

Re: help for conversion of NUMARRAY to PIL object

2005-09-16 Thread A. L.
Sorry, I make the mistakes. I have known how to use to/fromstring method to interface between PIL and Numarray. And your code does work. Another question. Just like the code you provide, is it possible to directly load image data from PIL to Numarray array without use of to/fromstring method?

Re: How to clear screen in Python interactive shell mode?

2005-09-16 Thread A. L.
Thank you very much. I have tested it under Cygwin, and that works. But it fails under Windows Python Shell Mode. -- http://mail.python.org/mailman/listinfo/python-list

Is There the Equivalent of FLT_EPS of C In Python?

2005-09-16 Thread A. L.
I am writing the code involved in numerical computation. When I need a float epsilon similar to FLT_EPS in C, eps in matlab, I fail to find the equivalent in python. Could somebody here can give me some advices? -- http://mail.python.org/mailman/listinfo/python-list

Re: How to clear screen in Python interactive shell mode?

2005-09-16 Thread A. L.
I have tested it under windows python console, and it works. Thank you very much. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is There the Equivalent of FLT_EPS of C In Python?

2005-09-16 Thread A. L.
Thank you very much. I have searched in python's documentation, and I am sure that python doesn't provide an epsilon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is There the Equivalent of FLT_EPS of C In Python?

2005-09-16 Thread A. L.
According to pp 134 of "C: A Reference Manual", it's better to use eps*2 in your code. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is map() preferable in this case?

2005-09-18 Thread Devan L
Ray wrote: > Hello, > > I'm just reading the latest edition of Python Cookbook, where it says > in Recipe 4.2: > > "when the op you wanna perform on each item is to call a function on > the item and use the function's result, use L1 = map(f, L), rather than &

winapi32.GetFileVersionInfo() - problem

2005-03-24 Thread L. Shestov
I need to be able to programatically get the version info from a windows DLL preferably in the same format as what is displayed in the properties tab. I was overjoyed to find Mark Hammond's Python Extensions (http://starship.python.net/crew/mhammond/) The package includes a little demo progr

Re: win32api.GetFileVersionInfo - error

2005-03-24 Thread L. Shestov
Sorry, I seem to be missing the replies! I will stop posting! Peter Hansen wrote: xytho33 wrote: I need to be able to programatically get the version info from a windows DLL preferably in the same format as what is displayed in the properties tab. (Posted and mailed) Your posts are making it to t

Python List Issue

2005-03-27 Thread Nick L
I've hit a brick wall on something that I'm guessing is pretty simple but it's driving me nuts. I noticed that with python lists, generally when you make a copy of a list (ie, List1 = List2) List1 just becomes a reference to List2 and any modifications done to List1 affects List2. Ok I can live wit

Re: Python List Issue

2005-03-27 Thread Nick L
> See copy.deepcopy(). It will make sure that everything gets copied and > nothing just referenced (more or less). So far copy.deepcopy() seems to be working perfectly. Thanks for the input Nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Python List Issue

2005-03-27 Thread Nick L
Thanks, thats a really handy function "Ron_Adam" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Sun, 27 Mar 2005 09:01:20 GMT, "Nick L" <[EMAIL PROTECTED]> > wrote: > > >I've hit a brick wall on something that I'm guess

Re: function inclusion problem

2015-02-11 Thread Victor L
Laura, thanks for the answer - it works. Is there some equivalent of "include" to expose every function in that script? Thanks again, -V On Tue, Feb 10, 2015 at 7:16 PM, Laura Creighton wrote: > In a message of Wed, 11 Feb 2015 01:06:00 +0100, Laura Creighton writes: > >In a message of Tue, 10 F

compare two list of dictionaries

2013-10-03 Thread Mohan L
me': 'hostname8', 'ip_addr': ''}, {'hostname': 'hostname200', 'ip_addr': 'xxx.xx.xxx.200'}, {'hostname': 'hostname300', 'ip_addr': 'xxx.xx.xxx.400'}, ) trying to get the following difference from the above dictionary 1). compare the value of 'ip' in output1 dictionary with either 'hostname' and 'ip_addr' output2 dictionary and print their intersection. Tried below code: for doc in output1: for row in output2: if((row["hostname"] == doc["ip"]) or (row["ip_addr"] == doc["ip"])): print doc["ip"],doc["count"] *output:* hostname1 212 hostname2 27 hostname10 1 hostname8 2 xxx.xx.xxx.11 3 xxx.xx.xxx.12 90 xxx.xx.xxx.13 12 xxx.xx.xxx.14 21 xxx.xx.xxx.15 54 xxx.xx.xxx.16 34 2). need to print the below output if the value of 'ip' in output1 dictionary is not there in in output2 dictionary(ip/hostname which is there in output1 and not there in output2): xxx.xx.xxx.1 3 xxx.xx.xxx.2 4 xxx.xx.xxx.3 8 xxx.xx.xxx.4 10 hostname3 513 hostname4 98 xxx.xx.xxx.17 11 xxx.xx.xxx.18 2 xxx.xx.xxx.19 19 xxx.xx.xxx.20 21 xxx.xx.xxx.21 25 xxx.xx.xxx.22 31 xxx.xx.xxx.23 43 xxx.xx.xxx.24 46 xxx.xx.xxx.25 80 xxx.xx.xxx.26 91 xxx.xx.xxx.27 90 xxx.xx.xxx.28 10 xxx.xx.xxx.29 3 3). Ip address with is there only in output2 dictionary. xxx.xx.xxx.200 xxx.xx.xxx.400 Any help would be really appreciated. Thank you Thanks Mohan L -- https://mail.python.org/mailman/listinfo/python-list

Re: compare two list of dictionaries

2013-10-03 Thread Mohan L
On Fri, Oct 4, 2013 at 12:14 AM, MRAB wrote: > On 03/10/2013 17:11, Mohan L wrote: > >> Dear All, >> >> I have two list of dictionaries like below: >> >> In the below dictionaries the value of ip can be either hostname or ip >> address. >> &

rhythmbox plugin problem

2015-06-24 Thread L E
Hello, I am trying to get some old plugins I wrote to wrote on anewer version of rhythmbox. When I try to load the plugin I see: (rhythmbox:3092): libpeas-WARNING **: nowplaying-lcd: /usr/lib/rhythmbox/plugins/nowplaying-lcd/libnowplaying-lcd.so: cannot open shared object file: No such file or d

Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Kenneth L
I'm a graphic designer. I'm new to Python. I know html, css, alittle actioscript and little javascript. I actually build an iOS using Flash. I understand programming concepts I believe. I'd like to build a Illustrator/Photoshop like program. Why, there are some features that I'd like to persona

Re: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Kenneth L
Well 15 years ago when I was 15 I wanted to model cars in 3D. It took me 100 hours and 5-10 years but I can modeling a realistic vehicle and other objects in 3d. It was time consuming and challenging but it was worth it. And honestly I've used my 3d modeling skills to build displays and products

Re: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Kenneth L
I tried to use gimp but as a photoshop user it was horrible. I was trying to like it. That is a great idea tearing down gimp. that is how I learn html and css. Breakin down websites. -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Kenneth L
No don't tell me what to do. I joined the military 3 years ago. You wouldn't believe the stuff I wasn't able to do before but now I am. You can keep your advice to yourself. I wasn't asking for something simple. I was asking for a starting point. The 3d was to show you I've learned hard stuff an

Re: How to quickly set up a multithreaded server that can handle http file post.

2013-03-11 Thread Xavier L.
On 13-03-11 10:42 AM, Shiyao Ma wrote: Today I come across a problem. Basically, my need is that I want to launch a http server that can not only support get but also support post (including post file). My first idea is to use -m http.sever. However, it only supports get. Later I find some one ex

Re: slice notation as values?

2005-12-10 Thread Devan L
Antoon Pardon wrote: > On 2005-12-10, Duncan Booth <[EMAIL PROTECTED]> wrote: [snip] > >> I also think that other functions could benefit. For instance suppose > >> you want to iterate over every second element in a list. Sure you > >> can use an extended slice or use some kind of while. But why n

Re: CGI module does not parse data

2005-12-16 Thread Devan L
amfr wrote: > I am writing a webserver, and I want it to be able to run python > scripts. But when I set sys.stdin to self.rfile (using the > BaseHTTPServer class, self.rfile is a input stream containing the > request), the cgi module does not parse the data. > Example script: > import cgi > form

Re: ANNOUNCE; Try python beta

2005-12-19 Thread Devan L
Mike Meyer wrote: > Ok, I've given it the interface I want, and made it less of an > attractive nuisance. > > http://www.mired.org/home/mwm/try_python/ is now ready for people to > play with. There's no tutorial information on it yet, that's the next > thing to do. However, I won't be able to work

ANN: (Different) Try Python Beta

2005-12-28 Thread Devan L
I've spent a while putting together a partially working Try Python which handles class and function definitions. It also (used to) work with imports, but my hacked version of jelly doesn't work with it anymore, so only import this works as far as I know. It won't play nice if you store the id of an

Re: ANN: (Different) Try Python Beta

2005-12-28 Thread Devan L
Steve Holden wrote: > Devan L wrote: [what I said] > At first I thought 'the cgitb TypeError message from "import os" is > impressively drastic :-)'. Then I realised in a later session that > "import os" only gave an error message after I'd run &qu

Re: Try Python update

2006-01-01 Thread Devan L
Mike Meyer wrote: > After spending time I should have been sleeping working on it, the try > python site is much more functional. It now allows statements, > including multi-line statements and expressions. You can't create code > objects yet, so it's still more a programmable calculator than > an

Re: Try Python update

2006-01-01 Thread Devan L
Mike Meyer wrote: > "Devan L" <[EMAIL PROTECTED]> writes: > >> If you want to try an online P{ython tool that lets you save code, try > >> Devan L's at http://www.datamech.com/devan/trypython/trypython.py. > > My code uses one of the recipes from th

Re: application and web app technologies

2006-01-03 Thread l v
ccc wrote: > [snip] We are just your basic IT shop, system > and network administration, hardware, help desk, the web site, and > database administration. This is also the reason for the 'bad code' ( > which we have in abundance.) People who are not programmers and whose > job it isn't to program w

Re: Try Python update

2006-01-03 Thread Devan L
[EMAIL PROTECTED] wrote: > I like the form, no matter what its limitations may be. Three notes: > > It might be a good way to catch newbi mistakes (those are the kind I > make :P, thereby providing a feedback loop to improved error messages. > > I had no trouble with from math import * followed b

Re: Try Python update

2006-01-03 Thread Devan L
Mike Meyer wrote: > [EMAIL PROTECTED] writes: [comments about Mike Meyer's try python, I think] > > I had no trouble with from math import * followed by print pi, but > > there was no >>> prompt after the result appeared .. is that part of > > the 'closures' thing mentioned earlier? > > Hmm. Are y

Re: Try Python update

2006-01-07 Thread Devan L
Mike Meyer wrote: > Xavier Morel <[EMAIL PROTECTED]> writes: [Old message and Xavier's question] [Mike's reply to Xavier] > > > Since Python doesn't have any way to secure the interface built-in, > > i'd be interrested in that. > > Devan apparently doesn't have as cooperative an ISP, and is working

(Different) Try Python Update

2006-01-14 Thread Devan L
It's been a while since I've done anything, and I have finals, so if anyone wants to look at some of the source, here's the somewhat cleaned up source for bastille and modjelly. Bastille is just a sort-of-more-secure equivalent of what the code module is, in case you have no clue what it does since

Re: Safe Python Execution

2006-02-15 Thread Devan L
Graham wrote: > I've been messing around with trying to get a small sandbox like > environment where i could execute python code in a "safe" way. > Basically what the old restricted execution module attempted to do. > I've written a small amount of code to get custom interpreter running, > but i'm

class memebers

2007-12-19 Thread N L
How do I list the members of a class? Meaning, how do I know what are the functions a particular class has, if i do not want to manually browse through the class? N Never miss a thing. Make Yahoo your

Creating instances of untrusted new-style classes

2006-05-25 Thread Devan L
Is there any safe way to create an instance of an untrusted class without consulting the class in any way? With old-style classes, I can recreate an instance from another one without worrying about malicious code (ignoring, for now, malicious code involving attribute access) as shown below. >>> im

Re: Creating instances of untrusted new-style classes

2006-05-25 Thread Devan L
Ben Finney wrote: > "Devan L" <[EMAIL PROTECTED]> writes: > > > Is there any safe way to create an instance of an untrusted class > > Why are you instantiating classes you don't trust? > > > without consulting the class in any way? > If you

Re: Creating instances of untrusted new-style classes

2006-05-25 Thread Devan L
Michael Spencer wrote: > Devan L wrote: > > Is there any safe way to create an instance of an untrusted class > > without consulting the class in any way? With old-style classes, I can > > recreate an instance from another one without worrying about malicious > &

Re: Windows Installer testing using python.

2008-11-28 Thread L. Lindstrom
://seul.org/svn/pygame/branches/msi -- Lenard Lindstrom "[EMAIL PROTECTED]" % ('len-l', 'telus', 'net') -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] Why don't range and xrange threat floats as floats?

2008-11-05 Thread L V
python 2.5 Since it was an indirect suggestion, I thought it belonged here. What should python-list and python-dev both be used for? I know there is an alternative, but why not make it easier? From: Matthieu Brucher <[EMAIL PROTECTED]> To: L V <[EMAIL

pyqt4: setText() inside a function

2009-04-16 Thread l . freschi
I'm developing a PyQt4 application. I have created a button: ... self.start_button=QtGui.QPushButton("start simulation", self) ... that is connected to a function: ... self.connect(self.start_button, QtCore.SIGNAL('clicked()'), self.simulate) ... This is the function: ... def simulate(self):

Re: pyqt4: setText() inside a function

2009-04-16 Thread l . freschi
On 16 Apr, 20:17, "Diez B. Roggisch" wrote: > l.fres...@gmail.com schrieb: > > > > > I'm developing a PyQt4 application. > > > I have created a button: > > ... > > self.start_button=QtGui.QPushButton("start simulation", self) > > ... > > > that is connected to a function: > > ... > > self.connect(

python segfaulting, MemoryError (PyQt)

2009-04-27 Thread Denis L
cter in barEdit, and then delete the character from barEdit I get an unhandled win32 exception occured in python.exe on windows and segfault on linux. If I type a character in fooEdit, delete it, and then type a character in barEdit I get: {'foo': PyQt4.QtCore.QString(u'a'),

Re: python segfaulting, MemoryError (PyQt)

2009-04-28 Thread Denis L
"Phil Thompson" wrote in message news:mailman.4664.1240907352.11746.python-l...@python.org... > On Tue, 28 Apr 2009 03:53:34 +0200, "Denis L" wrote: >> Hello, >> >> I'm experiencing odd errors on both windows and linux with the following >>

Re: python segfaulting, MemoryError (PyQt)

2009-04-28 Thread Denis L
"Phil Thompson" wrote in message news:mailman.4690.1240925876.11746.python-l...@python.org... > On Tue, 28 Apr 2009 14:54:41 +0200, "Denis L" wrote: >> "Phil Thompson" wrote in message >> news:mailman.4664.1240907352.11746.python-l...@python.

Re: python segfaulting, MemoryError (PyQt)

2009-04-28 Thread Denis L
"Phil Thompson" wrote in message news:mailman.4699.1240932385.11746.python-l...@python.org... > If there was a bug with lambda slots it's been fixed by now. I just tried it and I'm getting the same errors with regular functions. Could you try running the code bell

Re: python segfaulting, MemoryError (PyQt)

2009-04-29 Thread Denis L
"Phil Thompson" wrote in message news:mailman.4719.1240945001.11746.python-l...@python.org... > On Tue, 28 Apr 2009 19:07:30 +0200, "Denis L" wrote: >> "Phil Thompson" wrote in message >> news:mailman.4699.1240932385.11746.python-l...@python.org..

Python 2.6, building SDL for Pygame

2008-04-28 Thread L. Lindstrom
it is not critical then the SDL library will just use msvcrt.dll for Pygame and Python 2.6. -- Lenard Lindstrom "[EMAIL PROTECTED]" % ('len-l', 'telus', 'net') -- http://mail.python.org/mailman/listinfo/python-list

Python 2.6 and wrapping C libraries on Windows

2008-04-30 Thread L. Lindstrom
C run-time such as msvcrt? -- Lenard Lindstrom "[EMAIL PROTECTED]" % ('len-l', 'telus', 'net') -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.6 and wrapping C libraries on Windows

2008-04-30 Thread L. Lindstrom
Christian Heimes wrote: L. Lindstrom schrieb: I have read that Python extension modules must link to the same C run-time as the Python interpreter. This I can appreciate. But does this requirement extend to the C libraries an extension module wraps. The case in point is Pygame and SDL. The

Re: Python 2.6 and wrapping C libraries on Windows

2008-04-30 Thread L. Lindstrom
sturlamolden wrote: On Apr 30, 8:06 pm, "L. Lindstrom" <[EMAIL PROTECTED]> wrote: I have read that Python extension modules must link to the same C run-time as the Python interpreter. This I can appreciate. But does this requirement extend to the C libraries an extension modu

Re: Python 2.6 and wrapping C libraries on Windows

2008-04-30 Thread L. Lindstrom
L. Lindstrom wrote: Christian Heimes wrote: L. Lindstrom schrieb: [snip] [B]esides heap management and FILE pointers, is there any reason SDL, or any C dependency, needs to link to the same C run-time as Python? If I ensure SDL frees memory it allocates and does not directly access a file

removing a post

2009-09-28 Thread Mike L
hello could you remove this old post, off topic and spam http://www.mail-archive.com/python-list@python.org/msg175722.html thank you _ We are your photos. Share us now with Windows L

passing external data to web forms

2010-05-31 Thread M L
(Note: If you just skim this and can tell me how to pass data from an external program to a web form, that's all I need, and the rest is just what I'd like to have.) This is probably extremely simple when you know what you're doing. I figured I'd see if I could find a kind soul who could give me s

How to set up this usenet discussion?

2010-06-16 Thread L V
I have installed pan, but I fail to make it work with "news:comp.lang.python"; I tried adding the name as a newsserver and left all other info like Port, username and password empty. Stil I don't get any messages. How to fix this. Also I'm completely new to newsgroups. -- http://mail.pyt

removing a post from python

2010-10-21 Thread Mike L
http://www.mail-archive.com/python-list@python.org/msg175722.html hello could you remove above post... off topic and spam thank you -- http://mail.python.org/mailman/listinfo/python-list

Re: Better way to do this dict comprehesion

2017-04-01 Thread Robert L.
On 3/7/2017, Sayth Renshaw wrote: > I have got this dictionary comprehension and it > works but how can I do it better? > > from collections import Counter > > def find_it(seq): > counts = dict(Counter(seq)) > a = [(k, v) for k,v in counts.items() if v % 3 == 0] > return a[0][0] >

Re: How to flatten only one sub list of list of lists

2017-04-01 Thread Robert L.
On 3/1/2017, Sayth Renshaw wrote: > How can I flatten just a specific sublist of each list in a list of lists? > > So if I had this data > > > [ ['46295', 'Montauk', '3', '60', '85', ['19', '5', '1', '0 $277790.00']], > ['46295', 'Dark Eyes', '5', '59', '83', ['6', '4', '1', '0 $105625.00

Re: sorting list python

2017-04-01 Thread Robert L.
On 1/18/2017, Peter Otten wrote: > with partite.txt looking like this > > > 74' Kessie' > > 90' + 4' D'alessandro > > 51' Mchedlidze > > 54' Banega > > 56' Icardi > > 65' Icardi > > 14' Sau > > > Assuming you want to perform a numerical sort on the numbers before the ' > you can just apply sor

Re: Temporary variables in list comprehensions

2017-04-02 Thread Robert L.
On 1/8/2017, Steven D'Aprano wrote: > Suppose you have an expensive calculation that gets used two or > more times in a loop. The obvious way to avoid calculating it > twice in an ordinary loop is with a temporary variable: > > result = [] > for x in data: > tmp = expensive_calculation(x) >

.Re: scanf string in python

2017-04-21 Thread Robert L.
> > I have a string which is returned by a C extension. > > > > mystring = '(1,2,3)' > > > > HOW can I read the numbers in python ? > > re.findall seems the safest and easiest solution: > > >>> re.findall(r'(\d+)', '(1, 2, 3)') > ['1', '2', '3'] > >>> map(int, re.findall(r'(\d+)', '(1, 2, 3)')) >

Case insensitive dict

2013-05-21 Thread Joseph L. Casale
I was doing some work with the ldap module and required a ci dict that was case insensitive but case preserving. It turned out the cidict class they implemented was broken with respect to pop, it is inherited and not re implemented to work. Before I set about re-inventing the wheel, anyone know o

Ldap module and base64 oncoding

2013-05-24 Thread Joseph L. Casale
I have some data I am working with that is not being interpreted as a string requiring base64 encoding when sent to the ldif module for output. The base64 string parsed is ZGV0XDMzMTB3YmJccGc= and the raw string is det\3310wbb\pg. I'll admit my understanding of the handling requirements of non a

RE: Ldap module and base64 oncoding

2013-05-25 Thread Joseph L. Casale
> Can you give an example of the code you have? I actually just overrode the regex used by the method in the LDIFWriter class to be far more broad about what it interprets as a safe string. I really need to properly handle reading, manipulating and writing non ascii data to solve this... Shame

RE: authentication with python-ldap

2013-05-25 Thread Joseph L. Casale
> I have been doing the same thing and I tried to use java for testing the > credentials and they are correct. It works perfectly with java. > I really don´t know what we´re doing wrong. > > > You are accessing a protected operation of the LDAP server > and it (the server) rejects it due to invali

RE: Ldap module and base64 oncoding

2013-05-26 Thread Joseph L. Casale
> I'm not sure what exactly you're asking for. > Especially "is not being interpreted as a string requiring base64 encoding" is > written without giving the right context. > > So I'm just guessing that this might be the usual misunderstandings with use > of base64 in LDIF. Read more about when LDI

RE: Ldap module and base64 oncoding

2013-05-26 Thread Joseph L. Casale
x27;.join([attr_type,base64.encodestring(attr_value).replace('\n','')])) File "C:\Python27\lib\base64.py", line 315, in encodestring pieces.append(binascii.b2a_base64(chunk)) UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf'

RE: Ldap module and base64 oncoding

2013-05-27 Thread Joseph L. Casale
> Note that all modules in python-ldap up to 2.4.10 including module 'ldif' > expect raw byte strings to be passed as arguments. It seems to me you're > passing a Unicode object in the entry dictionary which will fail in case an > attribute value contains NON-ASCII chars. Yup, I was. > python-lda

Popen and reading stdout in windows

2013-06-10 Thread Joseph L. Casale
I have a use where writing an interim file is not convenient and I was hoping to iterate through maybe 100k lines of output by a process as its generated or roughly anyways. Seems to be a common question on ST, and more easily solved in Linux. Anyone currently doing this with Python 2.7 in windows

RE: Popen and reading stdout in windows

2013-06-10 Thread Joseph L. Casale
> You leave out an awful amount of detail. I have no idea what ST is, so > I'll have to guess your real problem. Ugh, sorry guys its been one of those days, the post was rather useless... I am using Popen to run the exe with communicate() and I have sent stdout to PIPE without luck. Just not su

Newbie: The philosophy behind list indexes

2013-06-14 Thread ian . l . cameron
I bet this is asked quite frequently, however after quite a few hours searching I haven't found an answer. What is the thinking behind stopping 'one short' when slicing or iterating through lists? By example; >>> a=[0,1,2,3,4,5,6] >>> a [0, 1, 2, 3, 4, 5, 6] >>> a[2:5] [2, 3, 4] To my mind,

Re: Newbie: The philosophy behind list indexes

2013-06-19 Thread ian . l . cameron
Thanks everyone for taking the time to offer some very insightful replies. Learning a new language is so much more fun with a group of friendly and helpful people around! -- http://mail.python.org/mailman/listinfo/python-list

Popen in Python3

2013-06-19 Thread Joseph L. Casale
I am trying to invoke a binary that requires dll's in two places all of which are included in the path env variable in windows. When running this binary with popen it can not find either, passing env=os.environ to open made no difference. Anyone know what might cause this or how to work around thi

Decorator help

2013-07-03 Thread Joseph L. Casale
I have a set of methods which take args that I decorate twice, def wrapped(func): def wrap(*args, **kwargs): try: val = func(*args, **kwargs) # some work except BaseException as error: log.exception(error) return [] return wra

RE: Decorator help

2013-07-03 Thread Joseph L. Casale
>> If you don't want to do that, you'd need to use introspection of a >> remarkably hacky sort. If you want that, well, it'll take a mo. > > After some effort I'm pretty confident that the hacky way is impossible. Hah, I fired it in PyCharm's debugger and spent a wack time myself, thanks for the c

RE: Decorator help

2013-07-04 Thread Joseph L. Casale
>Well, technically it's > >func.func_closure[0].cell_contents.__name__ > >but of course you cannot know that for the general case. Hah, I admit I lacked perseverance in looking at this in PyCharms debugger as I missed that. Much appreciated! jlc -- http://mail.python.org/mailman/listinfo/python

List comp help

2013-07-14 Thread Joseph L. Casale
I have a dict of lists. I need to create a list of 2 tuples, where each tuple is a key from the dict with one of the keys list items. my_dict = { 'key_a': ['val_a', 'val_b'], 'key_b': ['val_c'], 'key_c': [] } [(k, x) for k, v in my_dict.items() for x in v] This works, but I need to t

RE: List comp help

2013-07-14 Thread Joseph L. Casale
> Yeah, it's remarkably easy too! Try this: > > [(k, x) for k, v in my_dict.items() for x in v or [None]] > > An empty list counts as false, so the 'or' will then take the second option, > and iterate over the one-item list with > > None in it. Right, I overlooked that! Much appreciated, jlc --

sqlite3 version lacks instr

2013-07-28 Thread Joseph L. Casale
I have some queries that utilize instr wrapped by substr but the old version shipped in 2.7.5 doesn't have instr support. Has anyone encountered this and utilized other existing functions within the shipped 3.6.21 sqlite version to accomplish this? Thanks, jlc -- http://mail.python.org/mailman/l

RE: sqlite3 version lacks instr

2013-07-28 Thread Joseph L. Casale
> Has anyone encountered this and utilized other existing functions > within the shipped 3.6.21 sqlite version to accomplish this? Sorry guys, forgot about create_function... -- http://mail.python.org/mailman/listinfo/python-list

Providing a Python wrapper to a C++ type.

2012-10-16 Thread aaron . l . france
Hi, I have a C++ module where I have a defined, working type. How would I make a wrapper for this type to be able to be used in Python? I am familiar(-ish) with the C-API for functions but I can't see concretely how one would include an interface to a type. Is it this? http://docs.python.org/r

Simple Python question for some

2012-10-28 Thread Mark L. Hotz
I have what I think should be a relatively simple question for someone who is knowledgeable about Python. At the IDLE prompt, when I enter "b" > 99, it responds True. In fact, it doesn't matter which number is entered here, "b" is always greater (e.g. "b" > 1 == True; "b" > 10 == True, or "

Robust regex

2012-11-19 Thread Joseph L. Casale
Trying to robustly parse a string that will have key/value pairs separated by three pipes, where each additional key/value (if more than one exists) will be delineated by four more pipes. string = 'key_1|||value_1key_2|||value_2' regex = '((?:(?!\|\|\|).)+)(?:\|\|\|)((?:(?!\|\|\|).)+)(

RE: Robust regex

2012-11-19 Thread Joseph L. Casale
> Regexes may be overkill here. A simple string split might be better: Yup, and much more robust as I was looking for. Thanks everyone! jlc -- http://mail.python.org/mailman/listinfo/python-list

Dict comprehension help

2012-12-05 Thread Joseph L. Casale
I get a list of dicts as output from a source I need to then extract various dicts out of. I can easily extract the dict of choice based on it containing a key with a certain value using list comp but I was hoping to use dict comp so the output was not contained within a list. reduce(lambda x,y:

RE: Dict comprehension help

2012-12-05 Thread Joseph L. Casale
> {k: v for d in my_list if d['key'] == value for (k, v) in d.items()} Ugh, had part of that backwards:) Nice! > However, since you say that all dicts have a unique value for > z['key'], you should never need to actually merge two dicts, correct? > In that case, why not just use a plain for loop

RE: Dict comprehension help

2012-12-06 Thread Joseph L. Casale
>You could put the loop into a helper function, but if you are looping >through the same my_list more than once why not build a lookup table > >my_dict = {d["key"]: d for d in my_list} > >and then find the required dict with > >my_dict[value] I suppose, what I failed to clarify was that for each l

<    1   2   3   4   5   6   7   >