Re: counting items

2005-01-12 Thread It's me
Oh, darn. I asked this kind of question before. Somebody posted an answer before: def flatten(seq): for x in seq: if hasattr(x, "__iter__"): for subx in flatten(x): yield subx else: yield x data = [[1,5,2],8,4] val_to_pos = {} for i,

Re: Refactoring; arbitrary expression in lists

2005-01-12 Thread Paul McGuire
"Frans Englich" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > As continuation to a previous thread, "PyChecker messages", I have a question > regarding code refactoring which the following snippet leads to: > > > > runner.py:200: Function (detectMimeType) has too many returns (11)

Re: counting items

2005-01-12 Thread It's me
Yes, Mark, I came up with almost the same code (after reading back old answers from this list): def flatten(seq): for x in seq: if hasattr(x, "__iter__"): for subx in flatten(x): yield subx else: yield x def count_item(data): return

Re: OT: MoinMoin and Mediawiki?

2005-01-12 Thread Paul Rubin
Alexander Schremmer <[EMAIL PROTECTED]> writes: > > How does it do that? It has to scan every page in the entire wiki?! > > That's totally impractical for a large wiki. > > So you want to say that c2 is not a large wiki? :-) I don't know how big c2 is. My idea of a large wiki is Wikipedia. My g

Re: counting items

2005-01-12 Thread Steven Bethard
Mark McEahern wrote: It's me wrote: Okay, I give up. What's the best way to count number of items in a list [that may contain lists]? a = [[1,2,4],4,5,[2,3]] def iterall(seq): for item in seq: try: for subitem in iterall(item): yield subitem except Typ

Re: complex numbers

2005-01-12 Thread Carl Banks
It's me wrote: > The world would come to a halt if all of a sudden nobody understands complex > numbers anymore. :-) Actually, it would oscillate out of control. -- CARL BANKS -- http://mail.python.org/mailman/listinfo/python-list

Re: Iteration over two sequences

2005-01-12 Thread Steven Bethard
Henrik Holm wrote: John Lenton <[EMAIL PROTECTED]> wrote: def dotproduct(a, b): psum = 0 for i in range(len(a)): psum += a[i]*b[i] return psum for this particular example, the most pythonic way is to do nothing at all, or, if you must call it dotproduct, from Numeric import dot as dotp

Re: Refactoring; arbitrary expression in lists

2005-01-12 Thread [EMAIL PROTECTED]
I can not break the original code in 2.4, if I try this: import os, sys class NoMimeError(Exception): pass def detectMimeType( filename ): extension = filename[-3:] basename = os.path.basename(filename) if extension == "php": return "application/x-php" elif extension == "cpp" or extension.endswit

Re: Refactoring; arbitrary expression in lists

2005-01-12 Thread Frans Englich
On Wednesday 12 January 2005 18:56, [EMAIL PROTECTED] wrote: > I can not break the original code in 2.4, if I try this: [...] > > So although the dictionary solution is much nicer nothing seems wrong > with your code as it is - or am I missing something? Nope, the current code works. I'm just lo

PyAr - Python Argentina 5th Meeting, tomorrow Thursday, Decimal t alk included

2005-01-12 Thread Batista, Facundo
Title: PyAr - Python Argentina 5th Meeting, tomorrow Thursday, Decimal talk included The Argentinian Python User Group, PyAr, will have its fifth meeting this Thursday, January 13th at 7:00pm. Please see http://pyar.decode.com.ar/Wiki/ProximaReunion for details (in Spanish.) Agenda --

Re: counting items

2005-01-12 Thread Bernhard Herzog
"It's me" <[EMAIL PROTECTED]> writes: > May be flatten should be build into the language somehow That shouldn't be necessary as it can easily be written in a single list comprehension: a = [[1,2,4],4,5,[2,3]] flat_a = [x for cur, rest in [[a[:1], a[1:]]] for x in cur if (not isin

Re: counting items

2005-01-12 Thread It's me
Thanks. May be flatten should be build into the language somehow "Paul McGuire" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "It's me" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Okay, I give up. > > > > What's the best way to count number of items in a

Re: ConfigParser - add a stop sentinel?

2005-01-12 Thread rzed
Larry Bates <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: [responding to the idea of placing a sentinel in an ini file, and modifying ConfigParser to stop receiving input when it is encountered]: > You should probably consider NOT doing what you suggest. You > would need to do some rath

Removing M2Crypto debug data in production code

2005-01-12 Thread Ola Natvig
Hi all I'm writing a SSL server and we are using M2Crypto as our SSL engine. What bothers me is that on every accept it prints a lot of 'junk-data' to my stdout. It would be nice if someone knew a way to get M2Crypto out of debug mode and into a more silent mode. LOOP: SSL accept: before/accept in

Re: Excel module for Python

2005-01-12 Thread Neil Benn
sam wrote: Simon Brunning wrote: On Wed, 12 Jan 2005 15:18:09 +0800, sam <[EMAIL PROTECTED]> wrote: I m wondering which Excel module is good to be used by Python? If you are on Windows, and you have Excel, then the Python for Windows extensions[1] are all you need to drive Excel via COM. O'Reilly'

Re: Securing a future for anonymous functions in Python

2005-01-12 Thread Donn Cave
In article <[EMAIL PROTECTED]>, Jacek Generowicz <[EMAIL PROTECTED]> wrote: > Donn Cave <[EMAIL PROTECTED]> writes: > > > List incomprehensions do not parse well in my eyes. > > Are you familiar with the Haskell syntax for list comprehensions? > > For example: > > http://www.zvon.org/other/ha

Re: counting items

2005-01-12 Thread Leif K-Brooks
Paul McGuire wrote: Considering how often this comes up, might there be a place for some sort of flatten() routine in the std dist, perhaps itertools? A problem I see is that itertools tries to work across all iterable types, but flattening can't always be a generalized operation. For instance, a

Re: counting items

2005-01-12 Thread Michael Hartl
There's a great function called "walk" at that iterates over arbitrary data (and is recursion-proof) at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/118845 It also supplies a recursion-proof way to flatten a list. (Once you can iterate over an arbitrary sequence, the flattened version

Re: OT: MoinMoin and Mediawiki?

2005-01-12 Thread Paul Rubin
Paul Rubin writes: > > > How does it do that? It has to scan every page in the entire wiki?! > > > That's totally impractical for a large wiki. > > > > So you want to say that c2 is not a large wiki? :-) > > I don't know how big c2 is. My idea of a large wiki is Wikip

Re: complex numbers

2005-01-12 Thread Scott David Daniels
Robert Kern wrote: Let's presume for a moment that complex is *not* a native data type in Python. How would we implement the above - cleanly? The reason for making complex a builtin is _not_ to ease a single program, but to create a convention allowing different modules which operate on complex nu

Re: Iteration over two sequences

2005-01-12 Thread John Lenton
> Downloading, installing, and getting to know numerical modules for > Python is mext on my list :). However, I was under the impression that > Numarray is preferred to Numeric -- is that correct? Are these two > competing packages? (Hopefully this is not flame war bait...) Numeric's dot uses, if

m2crypto + asynchronous + stunnel

2005-01-12 Thread Ktm
Hello, i tried the demo echod_asyn.py without any certification verification (I modified echod_lib.py) and when I connect on the port with stunnel I've got the following error : error: uncaptured python exception, closing channel <__main__.ssl_echo_channel connected 127.0.0.1:34593 at 0xb7c5560

Re: Iteration over two sequences

2005-01-12 Thread Scott David Daniels
Henrik Holm wrote: John Lenton <[EMAIL PROTECTED]> wrote: def dotproduct(a, b): psum = 0 for i in range(len(a)): psum += a[i]*b[i] return psum for this particular example, the most pythonic way is to do nothing at all, or, if you must call it dotproduct, from Numeric import dot as dotp

Re: counting items

2005-01-12 Thread Steven Bethard
Michael Hartl wrote: (Once you can iterate over an arbitrary sequence, the flattened version is just [element for element in walk(sequence)].) Or, better yet: list(walk(sequence)) Steve -- http://mail.python.org/mailman/listinfo/python-list

Re: Python & unicode

2005-01-12 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Michel Claveau - abstraction méta-galactique non triviale en fuite perpétuelle. wrote: > I understand, but I have a feeling of attempt at hegemony. Is english > language really least-common-denominator for a russian who writes into > cyrillic, or not anglophone chinese? >

encryption/decryption help

2005-01-12 Thread drs
Hi, I need to send secure data over an insecure network. To that end, I am needing to encrypt serialized data and then decrypt it. Is there a builtin way to do this in Python? MD5, SHA, etc encrypt, but I am not seeing a way to get back my data. Encryption is totally new to me, so any pointers o

Re: encryption/decryption help

2005-01-12 Thread Paul Rubin
"drs" <[EMAIL PROTECTED]> writes: > Hi, I need to send secure data over an insecure network. To that end, I am > needing to encrypt serialized data and then decrypt it. Is there a builtin > way to do this in Python? MD5, SHA, etc encrypt, but I am not seeing a way > to get back my data. No, Py

Re: OT: MoinMoin and Mediawiki?

2005-01-12 Thread Ian Bicking
Paul Rubin wrote: Paul Rubin writes: How does it do that? It has to scan every page in the entire wiki?! That's totally impractical for a large wiki. So you want to say that c2 is not a large wiki? :-) I don't know how big c2 is. My idea of a large wiki is Wikipedia. My

Re: Another look at language comparisons

2005-01-12 Thread Terry Reedy
>>> http://www.tbray.org/ongoing/When/200x/2004/12/08/-big/IMG_3061.jpg Here is the link giving the context for that picture http://tbray.org/ongoing/When/200x/2004/12/08/DynamicJava The other person is Larry Wall. Samuele Pedroni is in the next one. A rather interesting meeting. Terry J. Reedy

py2exe Excludes

2005-01-12 Thread Ed Leafe
I'm trying to make a Windows runtime for Dabo, and I want to exclude the framework code itself from the exe file, so that people can update with new releases as they are made. The relevant section of setup.py has: setup( # The first three parameters are not required, if at least a

Re: Newbie: Pythonwin

2005-01-12 Thread Steve Holden
Brent W. Hughes wrote: 1) I'm running a program within Pythonwin. It's taking too long and I want to stop/kill it. What do I do (other than ctrl-alt-del)? When PythonWin is running it puts an icon in the system tray. You can right-mouse on this icon and select "Break into running code". 2)

human readable IPTC field names

2005-01-12 Thread Jonah Bossewitch
Hi, I am using PIL's IptcImagePlugin to extract the IPTC tags from an image file. I was able to successfully retrieve the tags from the image (thanks!), but the results are keyed off of cryptic tuples. I found the lookup codes here - http://demo.imagefolio.com/demo/ImageFolio31_files/skins/coo

Re: OT: MoinMoin and Mediawiki?

2005-01-12 Thread Paul Rubin
Ian Bicking <[EMAIL PROTECTED]> writes: > That sounds like you'd be implementing your own filesystem ;) Yes, this shouldn't be any surprise. Implementing a special purpose file system what every database essentially does. > If you are just trying to avoid too many files in a directory, another >

dict.updated

2005-01-12 Thread Rick Morrison
Would there be any way to add a method to all dict objects that operated like the .update() method, but also returned a reference to the updated dict? .update() is clumsy to use inside of list comprehensions and the like. Or am I missing something? Thanks, Rick -- http://mail.python.org/mail

Re: encryption/decryption help

2005-01-12 Thread Daniel Bowett
MD5 and SHA are by their very nature one way encryption. You cannot decrypt them. A quick google for other encrytion methods found this: http://www.amk.ca/python/code/crypto.html What you will need to do is find an encryption methos that uses a key which you use to encrypt and decrypt the data

Re: encryption/decryption help

2005-01-12 Thread Philippe C. Martin
Did you look at pycrypto ? http://www.amk.ca/python/code/crypto.html Regards, Philippe -- *** Philippe C. Martin SnakeCard LLC www.snakecard.com *** -- http://mail.python.org/mailman/listinfo/python-list

Re: Refactoring; arbitrary expression in lists

2005-01-12 Thread Jeff Shannon
Paul McGuire wrote: "Frans Englich" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] #-- def detectMimeType( filename ): extension = filename[-3:] You might consider using os.path.splitext() here, instead of always assuming

Re: encryption/decryption help

2005-01-12 Thread Kartic
Hi, Can you use ssh tunneling? You will not be changing anything except add an extra ssh layer to tunnel your data through. There is how-to at http://www.ccs.neu.edu/groups/systems/howto/howto-sshtunnel.html (or you can google for tunneling) Please note you can not use MD5 as it is not reversibl

Re: Python & unicode

2005-01-12 Thread Serge Orlov
Michel Claveau - abstraction méta-galactique non triviale en fuite perpétuelle. wrote: > Hi ! > > Sorry, but I think that, for russians, english is an *add-on*, > and not a common-denominator. You miss the point, programs are not English writings, they are written in computer languages using libra

Re: Locale confusion

2005-01-12 Thread Jorgen Grahn
On 11 Jan 2005 05:49:32 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Jorgen Grahn wrote: > [snip] > >> >> frailea> cat foo >> import locale >> print locale.getlocale() >> locale.setlocale(locale.LC_CTYPE) >> print locale.getlocale() ... >> When I run it as a script it isn't though, and

Re: readline, rlcompleter

2005-01-12 Thread Mark Asbach
Hi Michele, > readline.parse_and_bind("tab: complete") > > but I don't find a list of recognized key bindings. The python readline module just wraps the GNU Readline Library, so you need to check the manuals of the latter. It's not that much text and you'll find the information needed at: http

GTK libs don't get events when wrapped for Python

2005-01-12 Thread Mark Asbach
Hi list, I've got a crazy problem: an application fully written C and using a third-party library that itself uses GTK to draw some GUI widgets works as expected. But if I wrap the lib with SWIG and use it in Python, everythings works but the GUI parts. In fact, it looks like the library doesn't

Re: pulling info from website

2005-01-12 Thread Jorgen Grahn
On 10 Jan 2005 16:06:33 GMT, Duncan Booth <[EMAIL PROTECTED]> wrote: > bob wrote: > >> i am trying to write a script for Xbox media center that will pull >> information from the bbc news website and display the headlines , how >> do i pull this info into a list??? > > Google for "Python RSS reade

Re: dict.updated

2005-01-12 Thread Steven Bethard
Rick Morrison wrote: Would there be any way to add a method to all dict objects that operated like the .update() method, but also returned a reference to the updated dict? Are you looking for updated() to parallel sorted(), where sorted() returns a *new* list? I doubt you'll be able to rally much

Re: encryption/decryption help

2005-01-12 Thread Jorgen Grahn
On 12 Jan 2005 12:39:05 -0800, Kartic <[EMAIL PROTECTED]> wrote: > Hi, > > Can you use ssh tunneling? You will not be changing anything except add > an extra ssh layer to tunnel your data through. Or, rather, he wouldn't be changing anything at all in the program itself. The approach would be "Ok

Re: "Architecture of Python" was removed ?

2005-01-12 Thread Jon Perez
Skip Montanaro wrote: Yes, perhaps. Note that it doesn't appear that the Wayback Machine contains the meat of the essay, just the front page. It came from a wiki. Perhaps Most of the text seems to be there, but there are some critical diagrams (images) which the Wayback Machine did not archive.

Re: counting items

2005-01-12 Thread Michael Hartl
That's cool! Of course, walk returns a generator, so using a list comprehension to turn it into a list seems natural, but I didn't realize that list() does the same thing (and neither, apparently, did the original implementor) -- although, with a little reflection, it obviously must! Michael --

Re: Python serial data aquisition

2005-01-12 Thread Flavio codeco coelho
[EMAIL PROTECTED] (Flavio codeco coelho) wrote in message news:<[EMAIL PROTECTED]>... > struct.unpack returns a tuple of values represented by a string(the > output of the read command) packed according to the format specified > by ">BB" > In this forma string, ">" stands for big Endian representa

Re: reference or pointer to some object?

2005-01-12 Thread Torsten Mohr
Hi, thank you all for your explanations. I still wonder why a concept like "references" was not implemented in Python. I think it is (even if small) an overhead to wrap an object in a list or a dictionary. Isn't it possible to extend Python in a way to use real references? Or isn't that regard

pyserial and com port interrupts

2005-01-12 Thread engsol
Has anyone done a script that will rspond to the serial com port(s) receive buffer interrupt, as opposed to polling and timeouts? Win2000 is the main interest right now. Thanks Norm B -- http://mail.python.org/mailman/listinfo/python-list

Re: encryption/decryption help

2005-01-12 Thread Philippe C. Martin
>>MD5 and SHA are by their very nature one way encryption. You cannot decrypt them. Indeed, the point of these algorithms is to sign data (like a fingerprint). In order to encrypt you may go for Symmetrical algos (AES, 3DES with those, the key must be known on both sides of the pipe) or Asym

list and generators (WAS: counting items)

2005-01-12 Thread Steven Bethard
Michael Hartl wrote: That's cool! Of course, walk returns a generator, so using a list comprehension to turn it into a list seems natural, but I didn't realize that list() does the same thing (and neither, apparently, did the original implementor) -- although, with a little reflection, it obviousl

Re: encryption/decryption help

2005-01-12 Thread elbertlev
For the problem described pycrypto is the best solution. Blowfish is simple and secure. The method you want to use is called "security by obscurity". But chances are very high that the "homebrewed" scheme you will invent will not stand any serious crytoatack. First of all: both sides (sender and

pyXLwriter and jython

2005-01-12 Thread elbertlev
Hi! I was using pyXLwriter in C-python, but recently had to code in jython. Tried to port pyXLwriter to jython and it does not work. Did somebody uset this module with jython? -- http://mail.python.org/mailman/listinfo/python-list

Re: pyserial and com port interrupts

2005-01-12 Thread Peter Hansen
engsol wrote: Has anyone done a script that will rspond to the serial com port(s) receive buffer interrupt, as opposed to polling and timeouts? Win2000 is the main interest right now. What problem do you hope to avoid by not using "polling and timeouts"? (Note that if you specify a sizable read t

Re: shutil.move has a mind of its own

2005-01-12 Thread Steve Holden
Daniel Bickett wrote: Hello, I'm writing an application in my pastime that moves files around to achieve various ends -- the specifics aren't particularly important. The shutil module was chosen as the means simply because that is what google and chm searches returned most often. My problem has to

RE: What strategy for random accession of records in massive FAST A file?

2005-01-12 Thread Batista, Facundo
Title: RE: What strategy for random accession of records in massive FASTA file? [Chris Lasher] #- I have a rather large (100+ MB) FASTA file from which I need to #- access records in a random order. The FASTA format is a #- standard format #- for storing molecular biological sequences. Each

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-12 Thread Steve Holden
Paul Rubin wrote: [EMAIL PROTECTED] writes: 2. One could proposed hygienic pattern-matching macros in Python, similar to Scheme syntax-rules macros. Again, it is not obvious how to implement pattern-matching in Python in a non-butt-ugly way. Plus, I feel hygienic macros quite limited and not worth

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-12 Thread Steve Holden
Paul Rubin wrote: [EMAIL PROTECTED] writes: I can't imagine how it could be worse than the learning curve of __metaclass__, which we already have. To me, learning macros *and their subtilities* was much more difficult than learning metaclasses. I guess I've only used Lisp macros in pretty straight

Re: What strategy for random accession of records in massive FASTA file?

2005-01-12 Thread Fredrik Lundh
Chris Lasher wrote: > Since the file I'm working with contains tens of thousands of these > records, I believe I need to find a way to hash this file such that I > can retrieve the respective sequence more quickly than I could by > parsing through the file request-by-request. However, I'm very new

Re: What strategy for random accession of records in massive FASTA file?

2005-01-12 Thread James Stroud
Don't fight it, lite it! You should parse the fasta and put it into a database: http://www.sqlite.org/index.html Then index by name and it will be superfast. James -- http://mail.python.org/mailman/listinfo/python-list

Dynamically add class method causes "SystemError: ... bad argument to internal function"

2005-01-12 Thread Newgene
Hi, group, I am trying to dynamically add a method to class by following this post: http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/2ec2ad7a0a5d54a1/928e91be352c6bfc?q=%22new.code(%22+%22import+new&_done=%2Fgroup%2Fcomp.lang.python%2Fsearch%3Fgroup%3Dcomp.lang.python%26q%

What strategy for random accession of records in massive FASTA file?

2005-01-12 Thread Chris Lasher
Hello, I have a rather large (100+ MB) FASTA file from which I need to access records in a random order. The FASTA format is a standard format for storing molecular biological sequences. Each record contains a header line for describing the sequence that begins with a '>' (right-angle bracket) foll

Re: Securing a future for anonymous functions in Python

2005-01-12 Thread Jeff Shannon
Jacek Generowicz wrote: One more question. Imagine that Python had something akin to Smalltalk code blocks. Would something like map([x | x+1], seq) be any better for you than map(lambda x:x+1, seq) ? I'd say that this is very slightly better, but it's much closer (in my mind) to map/lambd

Re: Another look at language comparisons

2005-01-12 Thread Terry Reedy
"Jon Perez" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Anyone know of a cached copy where the photos are present? > > The whole thing makes little sense with the photos gone. > > Pierre Quentel wrote: >> http://khason.biz/blog/2004/12/why-microsoft-can-blow-off-with-c.html It

Re: What strategy for random accession of records in massive FASTA file?

2005-01-12 Thread John Lenton
> If you could help me figure out how to code a solution > that won't be a resource whore, I'd be _very_ grateful. (I'd prefer to > keep it in Python only, even though I know interaction with a > relational database would provide the fastest method--the group I'm > trying to write this for does not

Release date for 2nd edn. Cookbook

2005-01-12 Thread Simon Foster
Does anyone have any idea on this date? Any chance of a signed copy for contributors? -- http://mail.python.org/mailman/listinfo/python-list

Re: Another look at language comparisons

2005-01-12 Thread Jon Perez
Anyone know of a cached copy where the photos are present? The whole thing makes little sense with the photos gone. Pierre Quentel wrote: http://khason.biz/blog/2004/12/why-microsoft-can-blow-off-with-c.html -- http://mail.python.org/mailman/listinfo/python-list

Re: OT: MoinMoin and Mediawiki?

2005-01-12 Thread Ian Bicking
Paul Rubin wrote: If you are just trying to avoid too many files in a directory, another option is to put files in subdirectories like: base = struct.pack('i', hash(page_name)) base = base.encode('base64').strip().strip('=') filename = os.path.join(base, page_name) Using subdirectories certainly k

Re: reference or pointer to some object?

2005-01-12 Thread Jeff Shannon
Torsten Mohr wrote: I still wonder why a concept like "references" was not implemented in Python. I think it is (even if small) an overhead to wrap an object in a list or a dictionary. Because Python uses a fundamentally different concept for variable names than C/C++/Java (and most other static

Re: What strategy for random accession of records in massive FASTA file?

2005-01-12 Thread Larry Bates
You don't say how this will be used, but here goes: 1) Read the records and put into dictionary with key of sequence (from header) and data being the sequence data. Use shelve to store the dictionary for subsequent runs (if load time is excessive). 2) Take a look at Gadfly (gadfly.sourceforge.net)

Re: else condition in list comprehension

2005-01-12 Thread Steve Holden
Nick Coghlan wrote: Luis M. Gonzalez wrote: Hi there, I'd like to know if there is a way to add and else condition into a list comprehension. I'm sure that I read somewhere an easy way to do it, but I forgot it and now I can't find it... for example: z=[i+2 for i in range(10) if i%2==0] what if I w

Re: Game programming in Python

2005-01-12 Thread baza
On Wed, 12 Jan 2005 09:49:50 +0800, Simon Wittber wrote: >> I'm looking for any books or on-line resources on game programming >> using Python. Does anyone have any advice? > > Hi Baza, > > If I you are as I assume, a programmer just starting out with game > programming, the best suggestion I c

Re: dict.updated

2005-01-12 Thread Rick Morrison
I could live with creating a new dict, sure (although it seems wasteful). I realize that something like this probably doesn't stand a chance of ever making it into the std library for what might be called "philosophical" reasons. I just want it for me (my personal philosophy runs more to the pragma

Re: else condition in list comprehension

2005-01-12 Thread Stephen Thorne
On 9 Jan 2005 12:20:40 -0800, Luis M. Gonzalez <[EMAIL PROTECTED]> wrote: > Hi there, > > I'd like to know if there is a way to add and else condition into a > list comprehension. I'm sure that I read somewhere an easy way to do > it, but I forgot it and now I can't find it... > > for example: >

Re: Why would I get a TypeEror?

2005-01-12 Thread Steve Holden
It's me wrote: For this code snip: a=3 . b=(1,len(a))[isinstance(a,(list,tuple,dict))] Why would I get a TypeError from the len function? Thanks, because the interpreter evaluates the tuple (1, len(a)) before applying the indexing to it. You are trying to be far too clever. The standard way

Re: OT: MoinMoin and Mediawiki?

2005-01-12 Thread Paul Rubin
Ian Bicking <[EMAIL PROTECTED]> writes: > If the data has to be somewhere, and you have to have relatively > random access to it (i.e., access any page; not necessarily a chunk of > a page), then the filesystem does that pretty well, with lots of good > features like caching and whatnot. I can't s

Re: Iteration over two sequences

2005-01-12 Thread Terry Reedy
"It's me" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I tried this and I got: > [(1, 'a'), (2, 'b'), (3, 'c')] > But if I change: > a=[1,2] > I got: > [(1, 'c')] > Why is that? I thought I should be getting: > [(1, 'a'),(2,'b')] > ? Cut and paste the actual input and output

Re: What strategy for random accession of records in massive FASTA file?

2005-01-12 Thread Terry Reedy
RE: What strategy for random accession of records in massive FASTA file? "Batista, Facundo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [If you want to keep the memory usage low, you can parse the file once and store in a list the byte position where the record starts and ends. Th

Re: Octal notation: severe deprecation

2005-01-12 Thread PJDM
John Machin wrote: > > 1. Octal notation is of use to systems programmers on computers where > the number of bits in a word is a multiple of 3. Are there any still in > production use? AFAIK word sizes were 12, 24, 36, 48, and 60 bits -- > all multiples of 4, so hexadecimal could be used. The PDP-

Re: What strategy for random accession of records in massive FASTA file?

2005-01-12 Thread David E. Konerding DSD staff
In article <[EMAIL PROTECTED]>, Chris Lasher wrote: > Hello, > I have a rather large (100+ MB) FASTA file from which I need to > access records in a random order. The FASTA format is a standard format > for storing molecular biological sequences. Each record contains a > header line for describing

Re: Why would I get a TypeEror?

2005-01-12 Thread Terry Reedy
"Peter Hansen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > What did you expect the "length" of the integer 3 to be? Perhaps 2 (bits in a minimal binary representation). I once, for maybe a minute, considered proposing this as an overloaded meaning of len, but realized that th

Re: reference or pointer to some object?

2005-01-12 Thread JCM
Torsten Mohr <[EMAIL PROTECTED]> wrote: ... > I still wonder why a concept like "references" was not > implemented in Python. I think it is (even if small) > an overhead to wrap an object in a list or a dictionary. > Isn't it possible to extend Python in a way to use > real references? Or isn't

Re: else condition in list comprehension

2005-01-12 Thread Steven Bethard
Steve Holden wrote: Nick Coghlan wrote: z = [newval(i) for i in range(10)] using: def newval(x): if x % 2: return x - 2 else: return x + 2 Just some more mental twiddling relating to the thread on statement local namespaces. I presume the point of this

Re: What strategy for random accession of records in massive FASTA file?

2005-01-12 Thread John Machin
Chris Lasher wrote: > Hello, > I have a rather large (100+ MB) FASTA file from which I need to > access records in a random order. The FASTA format is a standard format > for storing molecular biological sequences. Each record contains a > header line for describing the sequence that begins with a

Re: reference or pointer to some object?

2005-01-12 Thread Steven Bethard
Jeff Shannon wrote: Torsten Mohr wrote: I still wonder why a concept like "references" was not implemented in Python. I think it is (even if small) an overhead to wrap an object in a list or a dictionary. Because Python uses a fundamentally different concept for variable names than C/C++/Java (an

Re: dict.updated

2005-01-12 Thread Steven Bethard
Rick Morrison wrote: I could live with creating a new dict, sure (although it seems wasteful). I realize that something like this probably doesn't stand a chance of ever making it into the std library for what might be called "philosophical" reasons. I just want it for me (my personal philosophy ru

Re: reference or pointer to some object?

2005-01-12 Thread Steven Bethard
Torsten Mohr wrote: I still wonder why a concept like "references" was not implemented in Python. I think it is (even if small) an overhead to wrap an object in a list or a dictionary. Isn't it possible to extend Python in a way to use real references? Or isn't that regarded as necessary? IMHO it

Matrix-SIG archives

2005-01-12 Thread Robert Kern
It looks like the mailing list archives for the Matrix-SIG and other retired SIGs are down at the moment. I've alerted the python.org webmaster, but in the meantime, does anyone have the early archives sitting around somewhere? I'm trying to answer a question about the motivations of a particul

Re: Why would I get a TypeEror?

2005-01-12 Thread Steven Bethard
It's me wrote: For this code snip: a=3 b=(1,len(a))[isinstance(a,(list,tuple,dict))] Why would I get a TypeError from the len function? You're looking for lazy evaluation or short-circuiting behavior. Python provides one form of short circuiting behavior with 'and' and 'or', though you need

Re: Refactoring; arbitrary expression in lists

2005-01-12 Thread Bengt Richter
On Wed, 12 Jan 2005 18:16:23 +, Frans Englich <[EMAIL PROTECTED]> wrote: > >As continuation to a previous thread, "PyChecker messages", I have a question >regarding code refactoring which the following snippet leads to: > >> > runner.py:200: Function (detectMimeType) has too many returns (11)

Re: Another look at language comparisons

2005-01-12 Thread Jon Perez
Terry Reedy wrote: It would hardly make more sense with the photos. The photos would be graphic evidence and would make it more entertaining to read through. "Not the law is clear? There is a beard - there is a success. There is no beard - you are guilty. " Terry J. Reedy And what about the moust

Re: dict.updated

2005-01-12 Thread hanz
Rick Morrison wrote: > >>> [updated(d, {'c':3}) for d in [{'a':1, 'b':2}, {'x':10, 'y':'11'}]] > [{'a': 1, 'c': 3, 'b': 2}, {'y': '11', 'x': 10, 'c': 3}] I don't really understand the use of this. Can you give a less toy example? I'd probably just do dicts = [{'a':1, 'b':2}, {'x':10, 'y':'11'}]

Re: dict.updated

2005-01-12 Thread Stephen Thorne
On Wed, 12 Jan 2005 23:47:13 GMT, Rick Morrison <[EMAIL PROTECTED]> wrote: > I could live with creating a new dict, sure (although it seems wasteful). I > realize that something like this probably doesn't stand a chance of ever > making it into the std library for what might be called "philosophica

Re: pyserial and com port interrupts

2005-01-12 Thread engsol
On Wed, 12 Jan 2005 17:45:48 -0500, Peter Hansen <[EMAIL PROTECTED]> wrote: >engsol wrote: >> Has anyone done a script that will rspond to the serial com port(s) >> receive buffer interrupt, as opposed to polling and timeouts? >> Win2000 is the main interest right now. > >What problem do you hope

Re: what would you like to see in a 2nd edition Nutshell?

2005-01-12 Thread kery
Alex Martelli wrote: > Craig Ringer <[EMAIL PROTECTED]> wrote: > > > On Wed, 2004-12-29 at 23:54, Thomas Heller wrote: > > > > > I found the discussion of unicode, in any python book I have, insufficient. > > > > I couldn't agree more. I think explicit treatment of implicit > > conversion, the role

Re: counting items

2005-01-12 Thread Bengt Richter
On Wed, 12 Jan 2005 18:07:47 GMT, "Andrew Koenig" <[EMAIL PROTECTED]> wrote: >"It's me" <[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED] > >> What's the best way to count number of items in a list? >> >> For instance, >> >> a=[[1,2,4],4,5,[2,3]] >> >> I want to know how many items are

Re: Help Optimizing Word Search

2005-01-12 Thread snoe
With a list of letters: 'ABAE?S?' your implementation ran 3.5 times faster than the one from http://blog.vrplumber.com/427 (in 0.437 seconds vs 1.515) Without wildcards yours runs slightly quicker as well. I guess with the wildcards, using an re as a quick filter against each word, versus the tra

Re: Dynamically add class method causes "SystemError: ... bad argument to internal function"

2005-01-12 Thread Newgene
I have noticed that the exception was caused by the call of "self.f()" within my "_generic" function. It will raise SystemError exception whenever I refer to any method or attribute of "self" within "_generic" function. Otherwise, dynamically adding method works fine. I cannot figure out what's the

Re: dict.updated

2005-01-12 Thread Bengt Richter
On Wed, 12 Jan 2005 23:47:13 GMT, "Rick Morrison" <[EMAIL PROTECTED]> wrote: >I could live with creating a new dict, sure (although it seems wasteful). I >realize that something like this probably doesn't stand a chance of ever >making it into the std library for what might be called "philosophica

<    1   2   3   >