Re: Language mavens: Is there a programming with if then else ENDIF syntax?

2009-11-17 Thread nn
On Nov 16, 11:54 am, Steve Ferg steve.ferg.bitbuc...@gmail.com wrote: This is a question for the language mavens that I know hang out here. It is not Python related, except that recent comparisons of Python to Google's new Go language brought it to mind. NOTE that this is *not* a suggestion

Re: Question about file objects...

2009-12-02 Thread nn
On Dec 2, 9:14 am, J dreadpiratej...@gmail.com wrote: Something that came up in class... when you are pulling data from a file using f.next(), the file is read one line at a time. What was explained to us is that Python iterates the file based on a carriage return as the delimiter. But

Re: Question about file objects...

2009-12-03 Thread nn
On Dec 2, 6:56 pm, Terry Reedy tjre...@udel.edu wrote: J wrote: On Wed, Dec 2, 2009 at 09:27, nn prueba...@latinmail.com wrote: Is there a way to read the file, one item at a time, delimited by commas WITHOUT having to read all 16,000 items from that one line, then split them out

Re: Which is more pythonic?

2009-12-04 Thread nn
On Dec 3, 10:41 am, Filip Gruszczyński grusz...@gmail.com wrote: I have just written a very small snippet of code and started thinking, which version would be more pythonic. Basically, I am adding a list of string to combo box in qt. So, the most obvious way is: for choice in self.__choices:

Re: Py 3: Terminal script can't find relative path

2010-01-19 Thread nn
On Jan 19, 8:03 am, Gnarlodious gnarlodi...@gmail.com wrote: On Jan 18, 4:21 pm, John Bokma j...@castleamber.com wrote: Gnarlodious gnarlodi...@gmail.com writes: I am running a script in a browser that finds the file in subfolder Data: Content=Plist('Data/Content.plist') However,

Re: Arrrrgh! Another module broken

2010-01-19 Thread nn
On Jan 18, 11:37 am, Grant Edwards inva...@invalid.invalid wrote: On 2010-01-18, Jive Dadson notonthe...@noisp.com wrote: I just found another module that broke when I went to 2.6.  Gnuplot. Apparently one of its routines has a parameter named with.  That used to be okay, and now it's not.

Re: ctypes for AIX

2010-01-26 Thread nn
On Jan 25, 6:36 pm, Waddle, Jim jim.wad...@boeing.com wrote: Chris, Thanks for responding to my email. I apologize for the remark about python only being developed for windows. I got the impression when I was looking at the ActivePython web site and saw that the version of python that they

Re: Need help with a program

2010-01-28 Thread nn
On Jan 28, 10:50 am, evilweasel karthikramaswam...@gmail.com wrote: I will make my question a little more clearer. I have close to 60,000 lines of the data similar to the one I posted. There are various numbers next to the sequence (this is basically the number of times the sequence has been

Re: Need help with a program

2010-01-28 Thread nn
Arnaud Delobelle wrote: nn prueba...@latinmail.com writes: On Jan 28, 10:50 am, evilweasel karthikramaswam...@gmail.com wrote: I will make my question a little more clearer. I have close to 60,000 lines of the data similar to the one I posted. There are various numbers next

Re: Need help with a program

2010-01-29 Thread nn
Johann Spies wrote: On Thu, Jan 28, 2010 at 07:07:04AM -0800, evilweasel wrote: Hi folks, I am a newbie to python, and I would be grateful if someone could point out the mistake in my program. Basically, I have a huge text file similar to the format below: AGACTCGAGTGCGCGGA

Re: string to list when the contents is a list

2010-02-18 Thread nn
Wes James wrote: I have been trying to create a list form a string. The string will be a list (this is the contents will look like a list). i.e. [] or ['a','b'] The [] is simple since I can just check if value == [] then return [] But with ['a','b'] I have tried and get: a=['a','b']

Re: A more pythonish code

2010-02-25 Thread nn
prasad_chand wrote: Hi, I use python to do simple math problems as a hobby. I have made a program that finds the number of divisors(factors) of a given number. I am hoping to improve my language skills, specifically I would like to re-write the function prime_factors more gracefully.

Re: Can I specify regex group to return float or int instead of string?

2010-02-25 Thread nn
On Feb 25, 12:20 pm, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Thu, 25 Feb 2010 09:00:07 -0800, Jeremy wrote: On Feb 25, 9:41 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Thu, 25 Feb 2010 07:48:44 -0800, Jeremy wrote: I have a regular

Re: loop over list and process into groups

2010-03-04 Thread nn
lbolla wrote: On Mar 4, 3:57 pm, Sneaky Wombat joe.hr...@gmail.com wrote: [ {'vlan_or_intf': 'VLAN2021'},  {'vlan_or_intf': 'Interface'},  {'vlan_or_intf': 'Po1'},  {'vlan_or_intf': 'Po306'},  {'vlan_or_intf': 'VLAN2022'},  {'vlan_or_intf': 'Interface'},  {'vlan_or_intf':

Re: Evaluate my first python script, please

2010-03-04 Thread nn
On Mar 4, 2:30 pm, MRAB pyt...@mrabarnett.plus.com wrote: Pete Emerson wrote: I've written my first python program, and would love suggestions for improvement. I'm a perl programmer and used a perl version of this program to guide me. So in that sense, the python is perlesque This

Re: loop over list and process into groups

2010-03-05 Thread nn
mk wrote: Sneaky Wombat wrote: [ 'VLAN4065', 'Interface', 'Gi9/6', 'Po2', 'Po3', 'Po306', 'VLAN4068', 'Interface', 'Gi9/6', 'VLAN4069', 'Interface', 'Gi9/6',] Hey, I just invented a cute ;-) two-liner using list comprehensions: # alist = list above tmp,

Re: related lists mean value (golfed)

2010-03-09 Thread nn
Peter Otten wrote: Michael Rudolf wrote: Am 09.03.2010 13:02, schrieb Peter Otten: [sum(a for a,b in zip(x,y) if b==c)/y.count(c)for c in y] [1.5, 1.5, 8.0, 4.0, 4.0, 4.0] Peter ... pwned. Should be the fastest and shortest way to do it. It may be short, but it is not

Re: Extracting patterns after matching a regex

2009-09-08 Thread nn
On Sep 8, 9:55 am, Mart. mdeka...@gmail.com wrote: On Sep 8, 2:16 pm, Andreas Tawn andreas.t...@ubisoft.com wrote: Hi, I need to extract a string after a matching a regular expression. For example I have the string... s = FTPHOST: e4ftl01u.ecs.nasa.gov and once I match

Re: Extracting patterns after matching a regex

2009-09-08 Thread nn
On Sep 8, 10:27 am, pdpi pdpinhe...@gmail.com wrote: On Sep 8, 3:21 pm, nn prueba...@latinmail.com wrote: On Sep 8, 9:55 am, Mart. mdeka...@gmail.com wrote: On Sep 8, 2:16 pm, Andreas Tawn andreas.t...@ubisoft.com wrote: Hi, I need to extract a string after a matching

Re: Extracting patterns after matching a regex

2009-09-08 Thread nn
On Sep 8, 10:25 am, Mart. mdeka...@gmail.com wrote: On Sep 8, 3:21 pm, nn prueba...@latinmail.com wrote: On Sep 8, 9:55 am, Mart. mdeka...@gmail.com wrote: On Sep 8, 2:16 pm, Andreas Tawn andreas.t...@ubisoft.com wrote: Hi, I need to extract a string after a matching

Re: Extracting patterns after matching a regex

2009-09-08 Thread nn
On Sep 8, 11:19 am, Dave Angel da...@ieee.org wrote: Mart. wrote: snip I have been doing this to turn the email into a string email =ys.argv[1] f =open(email, 'r') s =str(f.readlines()) so FTPHOST isn't the first element, it is just part of a larger string. When I turn the email

Re: Extracting patterns after matching a regex

2009-09-08 Thread nn
On Sep 8, 12:16 pm, nn prueba...@latinmail.com wrote: On Sep 8, 11:19 am, Dave Angel da...@ieee.org wrote: Mart. wrote: snip I have been doing this to turn the email into a string email =ys.argv[1] f =open(email, 'r') s =str(f.readlines()) so FTPHOST isn't the first

Re: custom data warehouse in python vs. out-of-the-box ETL tool

2009-09-23 Thread nn
On Sep 22, 4:00 pm, snfctech tschm...@sacfoodcoop.com wrote: Does anyone have experience building a data warehouse in python?  Any thoughts on custom vs using an out-of-the-box product like Talend or Informatica? I have an integrated system Dashboard project that I was going to build using

Re: Poll: Do you use csv.Sniffer?

2009-09-25 Thread nn
On Sep 24, 10:26 pm, s...@pobox.com wrote: If you are a csv module user, I have a question for you:  Do you use the csv.Sniffer class?     o Yes, frequently     o Yes, on occasion     o I tried it a few times but don't use it now     o No, I don't need it     o No, never heard of it     o

Re: Using String for new List name

2009-09-29 Thread nn
On Sep 28, 7:37 pm, Scott scott.freem...@gmail.com wrote: On Sep 28, 2:00 pm, Dave Angel da...@ieee.org wrote: Scott wrote: Thank you fine folks for getting back with your answers! So down the road I do dictname[line42].append(new stuff). (or [var] if I'm looping through the dict)

Re: Why is this slower?

2009-10-06 Thread nn
On Oct 5, 12:46 pm, Joseph Reagle rea...@mit.edu wrote: I would think the commented code would be faster (fewer loops), but it is not (because of function calls).     #Average user_time = 5.9975 over 4 iterations     inSRC = set([bio.name for bio in bios.values()])     inEB = set([bio.name

Re: A stupid newbie question about output...

2009-10-20 Thread nn
On Oct 20, 2:23 pm, J dreadpiratej...@gmail.com wrote: Can someone explain why this code results in two different outputs? for os in comp.CIM_OperatingSystem ():  print os.Name.split(|)[0] + Service Pack, os.ServicePackMajorVersion  osVer = os.Name.split(|)[0] + Service Pack,

Re: Is this pylint error message valid or silly?

2009-06-19 Thread nn
On Jun 18, 8:56 pm, Matthew Wilson m...@tplus1.com wrote: Here's the code that I'm feeding to pylint:     $ cat f.py     from datetime import datetime     def f(c=today):         if c == today:                     c = datetime.today()         return c.date() And here's what pylint

Re: Is this pylint error message valid or silly?

2009-06-19 Thread nn
On Jun 18, 8:56 pm, Matthew Wilson m...@tplus1.com wrote: Here's the code that I'm feeding to pylint:     $ cat f.py     from datetime import datetime     def f(c=today):         if c == today:                     c = datetime.today()         return c.date() And here's what pylint

Re: Is this pylint error message valid or silly?

2009-06-19 Thread nn
On Jun 18, 8:56 pm, Matthew Wilson m...@tplus1.com wrote: Here's the code that I'm feeding to pylint:     $ cat f.py     from datetime import datetime     def f(c=today):         if c == today:                     c = datetime.today()         return c.date() And here's what pylint

Re: string character count

2009-06-30 Thread nn
On Jun 30, 1:56 pm, MRAB pyt...@mrabarnett.plus.com wrote: noydb wrote: If I have a string for a file name such that I want to find the number of characters to the left of the dot, how can that be done? I did it this way: x = text12345.txt dot = x.find('.') print dot Was curious

library search path when compiling python

2009-07-07 Thread nn
I am trying to compile python with ssl support but the libraries are not in /usr/lib but in /opt/freeware/lib. How do I add that folder to the default library search path? It looks like configure --libdir=DIR might do the job but I don't want to replace the default lib search path, just add an

Re: library search path when compiling python

2009-07-08 Thread nn
On Jul 7, 4:06 pm, Christian Heimes li...@cheimes.de wrote: nn wrote: I am trying to compile python with ssl support but the libraries are not in /usr/lib but in /opt/freeware/lib. How do I add that folder to the default library search path? It looks like configure --libdir=DIR might do

Re: tough-to-explain Python

2009-07-08 Thread nn
On Jul 7, 5:18 pm, kj no.em...@please.post wrote: In mailman.2796.1246997332.8015.python-l...@python.org Chris Rebert c...@rebertia.com writes: You might find the following helpful (partially): http://effbot.org/zone/call-by-object.htm Extremely helpful.  Thanks!  (I learned more from it

Re: strange python scripting error

2009-07-24 Thread nn
On Jul 23, 7:03 pm, Dave Angel da...@ieee.org wrote: Mark Tarver wrote: I have a very strange error.  I have two test python files test.py and python.py which contain the following code #!/usr/bin/python print Content-type: text/html print print html print centerHello,

Re: Overlap in python

2009-08-05 Thread nn
On Aug 5, 7:13 am, Marcus Wanner marc...@cox.net wrote: On 8/4/2009 6:09 PM, MRAB wrote:   parts = [(5, 9, a), (7, 10, b), (3, 6, c), (15, 20, d), (18, 23, e)]   parts.sort()   parts [(3, 6, 'c'), (5, 9, 'a'), (7, 10, 'b'), (15, 20, 'd'), (18, 23, 'e')]   # Merge overlapping

Re: syntax checker in python

2009-08-10 Thread nn
On Aug 7, 4:39 pm, horos11 horo...@gmail.com wrote: ps - I just realized that it isn't enough to do: python -c 'import /path/to/script' since that actually executes any statement inside of the script (wheras all I want to do is check syntax) So - let me reprhase that - exactly how can you

Re: The inverse of .join

2010-06-17 Thread nn
Neil Cerutti wrote: What's the best way to do the inverse operation of the .join function? -- Neil Cerutti split -- http://mail.python.org/mailman/listinfo/python-list

Re: new to python - trouble calling a function from another function

2010-08-06 Thread nn
On Aug 5, 2:01 pm, Daniel Urban urban.d...@gmail.com wrote: I'm building an elevator simulator for a class assignment. I recently ran into a roadblock and don't know how to fix it. For some reason, in my checkQueue function below, the call to self.goUp() is never executed. It is on the

Re: Regular expression issue

2010-08-09 Thread nn
On Aug 9, 9:18 am, genxtech jrmy.l...@gmail.com wrote: On Aug 8, 7:34 pm, Tim Chase python.l...@tim.thechases.com wrote: On 08/08/10 17:20, genxtech wrote: if re.search(search_string, in_string) != None: While the other responses have addressed some of the big issues, it's also good

Re: passing variables as object attributes

2010-08-16 Thread nn
On Aug 16, 10:08 am, Vikas Mahajan vikas.mahaja...@gmail.com wrote: On 16 August 2010 19:23, Nitin Pawar nitinpawar...@gmail.com wrote: you would need to define a class first with its attiributes and then you may want to initiate the variables by calling the class initilializer Actually I

Re: passing variables as object attributes

2010-08-16 Thread nn
On Aug 16, 10:08 am, Vikas Mahajan vikas.mahaja...@gmail.com wrote: On 16 August 2010 19:23, Nitin Pawar nitinpawar...@gmail.com wrote: you would need to define a class first with its attiributes and then you may want to initiate the variables by calling the class initilializer Actually I

Re: Searching for most pythonic/least stupid way to do something simple

2010-03-16 Thread nn
david jensen wrote: ... and of course i screwed up my outcomes... that should read outcomes=[[4,3,8,3,5],[3,4,8,3,5],[2,5,8,3,5],[1,6,8,3,5],[0,7,8,3,5]] For starters: def getOutcomes(myList=[2,5,8,3,5]): low_id = int(myList[0]myList[1]) amountToShare = 2*myList[low_id] remainder =

Re: Searching for most pythonic/least stupid way to do something simple

2010-03-17 Thread nn
Michael Torrie wrote: david jensen wrote: of course, changing nn's to: def getOutcomes(myList=[2,5,8,3,5]): low_id = int(myList[0]myList[1]) amountToShare = 2*myList[low_id] remainder = myList[not low_id]-myList[low_id] tail=list(myList[2:]) outcomes =

Re: short-circuiting any/all ?

2010-03-22 Thread nn
kj wrote: I have a list of items L, and a test function is_invalid that checks the validity of each item. To check that there are no invalid items in L, I could check the value of any(map(is_invalid, L)). But this approach is suboptimal in the sense that, no matter what L is, is_invalid

Unicode blues in Python3

2010-03-23 Thread nn
I know that unicode is the way to go in Python 3.1, but it is getting in my way right now in my Unix scripts. How do I write a chr(253) to a file? #nntst2.py import sys,codecs mychar=chr(253) print(sys.stdout.encoding) print(mychar) ./nntst2.py ISO8859-1 ý ./nntst2.py nnout2 Traceback (most

Re: Unicode blues in Python3

2010-03-23 Thread nn
Rami Chowdhury wrote: On Tuesday 23 March 2010 10:33:33 nn wrote: I know that unicode is the way to go in Python 3.1, but it is getting in my way right now in my Unix scripts. How do I write a chr(253) to a file? #nntst2.py import sys,codecs mychar=chr(253) print

Re: Unicode blues in Python3

2010-03-23 Thread nn
Gary Herron wrote: nn wrote: I know that unicode is the way to go in Python 3.1, but it is getting in my way right now in my Unix scripts. How do I write a chr(253) to a file? Python3 make a distinction between bytes and string(i.e., unicode) types, and you are still thinking

Re: Unicode blues in Python3

2010-03-23 Thread nn
Stefan Behnel wrote: nn, 23.03.2010 19:46: Actually what I want is to write a particular byte to standard output, and I want this to work regardless of where that output gets sent to. I am aware that I could do open('nnout','w',encoding='latin1').write(mychar) but I am porting

Re: Unicode blues in Python3

2010-03-24 Thread nn
Martin v. Loewis wrote: nn wrote: Stefan Behnel wrote: nn, 23.03.2010 19:46: Actually what I want is to write a particular byte to standard output, and I want this to work regardless of where that output gets sent to. I am aware that I could do open('nnout','w',encoding='latin1

Re: Unicode blues in Python3

2010-03-24 Thread nn
Steven D'Aprano wrote: On Tue, 23 Mar 2010 11:46:33 -0700, nn wrote: Actually what I want is to write a particular byte to standard output, and I want this to work regardless of where that output gets sent to. What do you mean work? Do you mean display a particular glyph or something

Re: Unicode blues in Python3

2010-03-24 Thread nn
Antoine Pitrou wrote: Le Tue, 23 Mar 2010 10:33:33 -0700, nn a écrit : I know that unicode is the way to go in Python 3.1, but it is getting in my way right now in my Unix scripts. How do I write a chr(253) to a file? #nntst2.py import sys,codecs mychar=chr(253) print

Re: Why these don't work??

2010-04-08 Thread nn
M. Hamed wrote: I'm trying the following statements that I found here and there on Google, but none of them works on my Python 2.5, are they too old? or newer? abc.reverse() import numpy reverse does not work on strings but does work on lists: x=list(abc) x.reverse() x ['c', 'b', 'a']

Re: Missing DLL in win98

2010-06-04 Thread nn
On Jun 4, 9:53 am, Spyder42 spyder1...@yahoo.com wrote: On Fri, 04 Jun 2010 15:32:15 +0200, Christian Heimes li...@cheimes.de wrote: So your response is either, you don't know if there is a fix, or 'No way in h377.' You couldn't figure out by my post that I already knew that? Let me

Re: Bunch 2.0 - a dict with a default

2010-11-19 Thread nn
On Nov 18, 8:45 pm, Phlip phlip2...@gmail.com wrote: Pythonistas: If everyone likes this post, then the code is a snippet for community edification. Otherwise, it's a question: How to do this kind of thing better? I want a dict() variant that passes these test cases:         map = Map()  

Re: use of __new__ to permit dynamic completion within (any?) IDE ?

2010-12-08 Thread nn
On Dec 7, 10:52 am, gst g.sta...@gmail.com wrote: Hi, I met a situation where I was passing an object created in/with an upper level module class to a lower level module class' instance in one of its __init__ argument and saving a ref of the upper object in that lower level class' new

Re: completely implicit interpolation based on a frame object

2010-12-09 Thread nn
On Dec 9, 2:29 am, Edward Peschko horo...@gmail.com wrote: Any ideas would be great on this, including pitfalls that people see in implementing it. http://docs.python.org/library/string.html#template-strings regards  Steve Steve, Thanks for the tip, I did look at templates and

Re: Deprecation warnings (2.7 - 3 )

2010-12-10 Thread nn
On Dec 9, 10:15 pm, rusi rustompm...@gmail.com wrote: In trying to get from 2.x to 3 Terry suggested I use 2.7 with deprecation warnings Heres the (first) set DeprecationWarning: Overriding __eq__ blocks inheritance of __hash__ in 3.x DeprecationWarning: callable() not supported in 3.x;

Re: Deprecation warnings (2.7 - 3 )

2010-12-10 Thread nn
On Dec 10, 11:17 am, nn prueba...@latinmail.com wrote: On Dec 9, 10:15 pm, rusi rustompm...@gmail.com wrote: In trying to get from 2.x to 3 Terry suggested I use 2.7 with deprecation warnings Heres the (first) set DeprecationWarning: Overriding __eq__ blocks inheritance of __hash__

Re: decouple copy of a list

2010-12-10 Thread nn
On Dec 10, 8:48 am, Dirk Nachbar dirk...@gmail.com wrote: I want to take a copy of a list a b=a and then do things with b which don't affect a. How can I do this? Dirk Not knowing the particulars, you may have to use: import copy b=copy.deepcopy(a) --

move to end, in Python 3.2 Really?

2011-01-17 Thread nn
I somehow missed this before. I like most of the additions from Raymond Hettinger. But the api on this baffles me a bit: d = OrderedDict.fromkeys('abcde') d.move_to_end('b', last=False) ''.join(d.keys) 'bacde' I understand that end could potentially mean either end, but would move_to_end

Re: move to end, in Python 3.2 Really?

2011-01-18 Thread nn
On Jan 18, 12:20 am, Raymond Hettinger pyt...@rcn.com wrote: On Jan 17, 6:51 pm, nn prueba...@latinmail.com wrote: ...But the api on this baffles me a bit: d = OrderedDict.fromkeys('abcde') d.move_to_end('b', last=False) ''.join(d.keys) 'bacde' I understand that end could

Re: itertools.groupby usage to get structured data

2011-02-07 Thread nn
On Feb 5, 7:12 am, Peter Otten __pete...@web.de wrote: Slafs wrote: Hi there! I'm having trouble to wrap my brain around this kind of problem: What I have :   1) list of dicts   2) list of keys that i would like to be my grouping arguments of elements from 1)   3) list of keys

Re: Executing functions

2011-02-11 Thread nn
On Feb 11, 9:15 am, DataSmash r...@new.rr.com wrote: Can someone help me understand why Example #1 Example #2 will run the functions, while Example #3 DOES NOT? Thanks for your time! R.D. def One():     print running fuction 1 def Two():     print running fuction 2 def Three():    

Re: Fun with 'str' and 'bytes'

2011-03-04 Thread nn
On Mar 4, 7:32 am, Frank Millman fr...@chagford.com wrote: Hi all I want to create a cookie containing a session id. In python 2.6 I had the following - from __future__ import unicode_literals session_id = b64encode(urandom(20)) response_headers.append(     (b'Set-Cookie',

Re: What is the best book to learn Python from Perl and C++ background

2011-03-04 Thread nn
On Mar 4, 12:49 pm, Ignoramus20691 ignoramus20...@NOSPAM. 20691.invalid wrote: I bought a Hello World! book for my 9 year old son. The book teached programming for kids and it does it in Python. I do not know any Python, but I am very comfortable with C++ and perl. I wrote a little over 100k

Re: generator expression works in shell, NameError in script

2009-06-18 Thread nn
On Jun 18, 8:38 am, guthrie grguth...@gmail.com wrote: On Jun 17, 6:38 pm, Steven Samuel Cole steven.samuel.c...@gmail.com wrote: Still don't really understand why my initial code didn't work, though... Your code certainly looks reasonable, and looks to me like it should work. The comment

Re: print or write on a text file ?

2012-10-01 Thread nn
On Sep 28, 2:42 pm, Franck Ditter fra...@ditter.org wrote: Hi ! Here is Python 3.3 Is it better in any way to use print(x,x,x,file='out') or out.write(x) ? Any reason to prefer any of them ? There should be a printlines, like readlines ? Thanks,     franck There is out.writelines(lst) --

Re: Python-URL! - weekly Python news and links (Mar 31)

2012-04-02 Thread nn
On Mar 31, 11:38 am, Cameron Laird claird...@gmail.com wrote: I pine for the fjords. And it's time to bring Python-URL! to a close.  Python-URL!, which Jean-Claude Wippler and I appear to have launched in 1998, has reached the end of its utility.  We still have many loyal and enthusiastic

Re: Is there a better way to do this snippet?

2012-04-03 Thread nn
On Apr 3, 11:02 am, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: python w.g.sned...@gmail.com writes: tag23gr is a list of lists each with two items. g23tag is an empty dictionary when I run the for loop below. When is is complete each key is a graphic name who's values are a list

Re: Is there a better way to do this snippet?

2012-04-03 Thread nn
On Apr 3, 12:26 pm, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: nn prueba...@latinmail.com writes: for item in tag23gr: ...        value, key = tuple(item) ...        if(g23tag.get(key)): ...                g23tag[key].append(value) ...        else

Re: how to count the total number of strings (in the list) used in Python?

2012-04-17 Thread nn
On Apr 16, 3:00 pm, Chinesekidz chinesek...@googlemail.com wrote: Hello! I would like to know how to write the program to count the total number of strings (in the list) used in Python.. for example: list:['1','2','3','4'] for l in range(4):      num=input(list:+list[l]+(between 1 and

Re: Working with Cursors

2012-04-17 Thread nn
On Apr 17, 2:11 pm, timlash timl...@gmail.com wrote: Searched the web and this forum without satisfaction.  Using Python 2.7 and pyODBC on Windows XP I can get the code below to run and generate two cursors from two different databases without problems.  Ideally, I'd then like to join these

Re: Working with Cursors

2012-04-17 Thread nn
On Apr 17, 2:11 pm, timlash timl...@gmail.com wrote: Searched the web and this forum without satisfaction.  Using Python 2.7 and pyODBC on Windows XP I can get the code below to run and generate two cursors from two different databases without problems.  Ideally, I'd then like to join these

Re: better way to do this in python

2011-04-04 Thread nn
On Apr 3, 8:06 am, Mag Gam magaw...@gmail.com wrote: Thanks for the responses. Basically, I have a large file with this format, Date INFO username command srcipaddress filename I would like to do statistics on: total number of usernames and who they are username and commands username and

Re: replace regex in file using a dictionary

2011-04-05 Thread nn
On Apr 5, 3:59 am, Martin De Kauwe mdeka...@gmail.com wrote: Hi, So i want to replace multiple lines in a text file and I have reasoned the best way to do this is with a dictionary. I have simplified my example and broadly I get what I want however I am now printing my replacement string and

Finding empty columns. Is there a faster way?

2011-04-21 Thread nn
time head -100 myfile /dev/null real0m4.57s user0m3.81s sys 0m0.74s time ./repnullsalt.py '|' myfile 0 1 Null columns: 11, 20, 21, 22, 23, 24, 25, 26, 27, 30, 31, 33, 45, 50, 68 real1m28.94s user1m28.11s sys 0m0.72s import sys def main(): with

Re: Finding empty columns. Is there a faster way?

2011-04-22 Thread nn
On Apr 21, 4:32 pm, Jon Clements jon...@googlemail.com wrote: On Apr 21, 5:40 pm, nn prueba...@latinmail.com wrote: time head -100 myfile  /dev/null real    0m4.57s user    0m3.81s sys     0m0.74s time ./repnullsalt.py '|' myfile 0 1 Null columns: 11, 20, 21, 22, 23

Re: Today's fun and educational Python recipe

2011-05-05 Thread nn
On May 4, 2:17 pm, Raymond Hettinger pyt...@rcn.com wrote: Here's a 22-line beauty for a classic and amazing algorithm:http://bit.ly/bloom_filter The wiki article on the algorithm is brief and well-written:http://en.wikipedia.org/wiki/Bloom_filter It turns out that people in the 1970's

Re: string formatting

2011-05-06 Thread nn
On May 6, 8:10 am, Web Dreamer webdrea...@nospam.fr wrote: Chris Rebert a écrit ce vendredi 6 mai 2011 11:23 dans mailman.1230.1304673808.9059.python-l...@python.org : I'm not them, but: Note: The formatting operations described here [involving %] are obsolete and may go away in future

Re: generate properties code in class dynamically

2011-05-12 Thread nn
On May 12, 9:11 am, JamesEM james.hous...@deutsche-boerse.com wrote: Hello, I have a python class that contains a dictionary. I would like to use python properties to access the elements of the dictionary. This could be achieved as follows: class MyClass(object):     def __init__(self):  

Re: What is the most efficient way to find similarities and differences between the contents of two lists?

2011-06-13 Thread nn
On Jun 13, 11:06 am, Zachary Dziura zcdzi...@gmail.com wrote: Hi all. I'm writing a Python script that will be used to compare two database tables. Currently, those two tables are dumped into .csv files, whereby my code goes through both files and makes comparisons. Thus far, I only have

Re: Python math is off by .000000000000045

2012-02-22 Thread nn
On Feb 22, 1:13 pm, Alec Taylor alec.tayl...@gmail.com wrote: Simple mathematical problem, + and - only: 1800.00-1041.00-555.74+530.74-794.95 -60.9500045 That's wrong. Proofhttp://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-... -60.95 aka (-(1219/20)) Is

Re: Minimum and Maximum of a list containing floating point numbers

2010-09-07 Thread nn
On Sep 6, 10:31 pm, Steven D'Aprano steve-REMOVE- t...@cybersource.com.au wrote: On Tue, 07 Sep 2010 11:00:45 +1000, Ben Finney wrote: If you're going to use the list of float objects, you can convert them all with a list comprehension. [...]     numbers_as_float = [float(x) for x in

Re: Ugh! Python 3.1.x and MySQL

2010-09-10 Thread nn
On Sep 10, 12:27 pm, fuglyducky fuglydu...@gmail.com wrote: Most of the python books coming out now are Py3K. I just started programming and have a need to access a MySQL database. I would like to use Python to do this. Unfortunately, I cannot find anyone that has created anything that allows

Re: business date and calendar libraries?

2010-09-15 Thread nn
On Sep 13, 3:02 pm, David Robinow drobi...@gmail.com wrote: On Mon, Sep 13, 2010 at 1:06 PM, Chris Withers ch...@simplistix.co.uk wrote: I'm wondering what libraries people would use to answer the following questions relating to business days: - on a less-naive level; same question but

Re: lists and list item matches (ghost wodgame)

2010-09-22 Thread nn
On Sep 21, 6:39 pm, Baba raoul...@gmail.com wrote: Hi query level: beginner as part of a learning exercise i have written code that: a) asks for a single letter input (assumption: only 1 letter wil be entered) b) adds that letter to list1 and then goes through list2 and checks:     1)

Re: lists and list item matches (ghost wodgame)

2010-09-23 Thread nn
On Sep 22, 6:39 pm, Baba raoul...@gmail.com wrote: On Sep 22, 9:18 pm, Baba raoul...@gmail.com wrote: On Sep 22, 3:38 pm, nn prueba...@latinmail.com wrote: On Sep 21, 6:39 pm, Baba raoul...@gmail.com wrote: Hi query level: beginner as part of a learning exercise i have

Re: lists and list item matches (ghost wodgame)

2010-09-23 Thread nn
On Sep 23, 10:56 am, nn prueba...@latinmail.com wrote: On Sep 22, 6:39 pm, Baba raoul...@gmail.com wrote: On Sep 22, 9:18 pm, Baba raoul...@gmail.com wrote: On Sep 22, 3:38 pm, nn prueba...@latinmail.com wrote: On Sep 21, 6:39 pm, Baba raoul...@gmail.com wrote: Hi query

Re: collections.namedtuple: conflicting instances?

2010-09-23 Thread nn
On Sep 23, 1:40 pm, Chris Rebert creb...@ucsd.edu wrote: On Thu, Sep 23, 2010 at 9:28 AM, David A. Barrett c_bar...@qualcomm.com wrote:  I've noticed that it's possible to create conflicting instances of the collections.namedtuple class:  from collections  import namedtuple as nt  

Re: lists and list item matches (ghost wodgame)

2010-09-23 Thread nn
On Sep 23, 1:25 pm, Baba raoul...@gmail.com wrote: On Sep 23, 4:17 pm, nn prueba...@latinmail.com wrote: On Sep 23, 10:56 am, nn prueba...@latinmail.com wrote: On Sep 22, 6:39 pm, Baba raoul...@gmail.com wrote: On Sep 22, 9:18 pm, Baba raoul...@gmail.com wrote: On Sep 22, 3:38

Re: lists and list item matches (ghost wodgame)

2010-09-24 Thread nn
On Sep 23, 8:46 pm, Baba raoul...@gmail.com wrote: On Sep 23, 8:13 pm, nn prueba...@latinmail.com wrote: On Sep 23, 1:25 pm, Baba raoul...@gmail.com wrote: On Sep 23, 4:17 pm, nn prueba...@latinmail.com wrote: On Sep 23, 10:56 am, nn prueba...@latinmail.com wrote: On Sep 22, 6

Re: Help with sets

2010-10-05 Thread nn
Semantic web.  I did get a bit confused in reading about the concept of sets in python and why you would use them instead of a dictionary for Sets are faster and more convenient to do intersections, unions, differences. They also use less space than dictionaries. Finally they also help

Re: Many newbie questions regarding python

2010-10-08 Thread nn
On Oct 7, 7:10 pm, Rogério Brito rbr...@ime.usp.br wrote: Hi there. I am used to some languages like C, but I am just a complete newbie with Python and, while writing some small snippets, I had encountered some problems, with which I would sincerely appreciate any help, since I appreciate

Re: Question regarding python2.5 migration from windows xp to windows 7

2010-10-14 Thread nn
On Oct 14, 2:37 am, python_tsp pramod...@gmail.com wrote: Hi, We have a Python based test framework which is being used in various projects. Our current environment is Python (ver 2.5.1) wxPython (wxPython2.8-win32-ansi-2.8.6.0-py25) pywin32-210.win32-py2.5 vcredist_x86.exe pyserial-2.2

Re: Why flat is better than nested?

2010-10-27 Thread nn
On Oct 25, 4:18 pm, Ethan Furman et...@stoneleaf.us wrote: kj wrote: In mailman.232.1288020268.2218.python-l...@python.org Steve Holden st...@holdenweb.com writes: On Oct 25, 5:07 am, kj no.em...@please.post wrote: In The Zen of Python, one of the maxims is flat is better than nested?

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-28 Thread nn
On Oct 28, 12:33 pm, cbr...@cbrownsystems.com cbr...@cbrownsystems.com wrote: On Oct 28, 9:23 am, John Posner jjpos...@optimum.net wrote: On 10/28/2010 12:16 PM, cbr...@cbrownsystems.com wrote: It's clear but tedious to write: if 'monday in days_off or tuesday in days_off:      

Re: Question about expression evaluation

2010-11-08 Thread nn
On Nov 8, 11:17 am, Scott Gould zinck...@gmail.com wrote: Hi folks, This is a head-scratcher to me. I occasionally get this error: ---   File /var/www/myproj/account/views.py, line 54, in account     if request.account.is_instructor and request.account.contact and

Re: Implicit initialization is EVIL!

2011-07-05 Thread nn
On Jul 4, 11:35 am, Robin Becker ro...@reportlab.com wrote: On 03/07/2011 23:21, Chris Angelico wrote: . var(0x14205359) x   # Don't forget to provide an address where the object will be located x=42 did you forget to specify the memory bank and computer (and

Re: testing if a list contains a sublist

2011-08-16 Thread nn
On Aug 16, 8:23 am, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: Roy Smith r...@panix.com writes: what is the best way to check if a given list (lets call it l1) is totally contained in a second list (l2)? [...] import re def sublist(l1, l2):     s1 = ''.join(map(str, l1))  

  1   2   >