Re: Accessing windows structures through ctypes.

2009-07-01 Thread Rajat
> > Using ctypes can I access the windows structures like: > > > PROCESS_INFORMATION_BLOCK, Process Environment Block(PEB), > > PEB_LDR_DATA, etc? > > ctypes.wintypes lists all of the Windows structures included with the > module. > > You should be able to use ctypes.Structure class to roll your o

Re: pep 8 constants

2009-07-01 Thread Eric S. Johansson
Steven D'Aprano wrote: > That assumes that every word is all caps. In practice, for real-life > Python code, I've tripled the vocal load of perhaps one percent of your > utterances, which cuts your productivity by 2%. > > If you have 1 words in you per day, and one percent get wrapped with

Re: Accessing windows structures through ctypes.

2009-07-01 Thread alex23
On Jul 2, 3:42 pm, Rajat wrote: > Using ctypes can I access the windows structures like: > > PROCESS_INFORMATION_BLOCK, Process Environment Block(PEB), > PEB_LDR_DATA, etc? ctypes.wintypes lists all of the Windows structures included with the module. You should be able to use ctypes.Structure cl

wxPython: Plaing widgets in status bar

2009-07-01 Thread iu2
Hi all, I try to placs widgets (button, static text labels) in a status bar, wxPython. >From the examples I could place them using exact positioning by the status bar methof GetFieldRect. In this case I need to add an EVT_SIZER handler to keep the widgets in their propotional places within the sta

Re: A question about fill_free_list(void) function

2009-07-01 Thread Pedram
On Jul 1, 10:01 pm, Christian Heimes wrote: > Pedram schrieb: > > > Hello community, > > I'm reading the CPython interpreter source code, > > first, if you have something that I should know for better reading > > this source code, I would much appreciate that :) > > second, in intobject.c file, I

dealloc function in python extend c module

2009-07-01 Thread Shen, Yu-Teh
I create my extend type something like http://www.python.org/doc/current/extending/newtypes.html. And my type has a member which is a pointer point to my allocate memory ( no ref count). ex: --- typedef struct { PyObject_HEAD /* Type-specific

Re: Accessing windows structures through ctypes.

2009-07-01 Thread Horace Blegg
http://www.codeproject.com/KB/threads/GetNtProcessInfo.aspx Looks rather to be pretty simple: Acquire the PED base pointer (article explains how) and then just read that information into a struct using ReadProcessMemory(). On Wed, Jul 1, 2009 at 10:42 PM, Rajat wrote: > Hi, > > Using ctypes can

Re: Basic question from pure beginner

2009-07-01 Thread alex23
Dennis Lee Bieber wrote: >         There is also the getpass module to play with! I don't think I've ever seen getpass, so thanks for pointing that out. Unfortunately, it wouldn't have helped the OP understand why his original code wasn't working ;) -- http://mail.python.org/mailman/listinfo/pyt

Re: Making code run in both source tree and installation path

2009-07-01 Thread Lawrence D'Oliveiro
In message , Robert Kern wrote: > On 2009-07-01 01:04, Carl Banks wrote: >> >> The most common way I've seen people work around this issue is to >> throw their data files into the package directories. Yuck. > > Huh. I always found that to be a more elegant solution than hardcoding the > data lo

Re: pep 8 constants

2009-07-01 Thread Eric S. Johansson
Rhodri James wrote: > > Gah. Ignore me. I hit 'send' instead of 'cancel', after my musings > concluded that yes, an editor could be smart enough, but it would have to > embed a hell of a lot of semantic knowledge of Python and it still wouldn't > eliminate the need to speak the keyboard at time

Accessing windows structures through ctypes.

2009-07-01 Thread Rajat
Hi, Using ctypes can I access the windows structures like: PROCESS_INFORMATION_BLOCK, Process Environment Block(PEB), PEB_LDR_DATA, etc? Regards, Rajat -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to use sets for random selection, but the pop() method returns items in order

2009-07-01 Thread Mario Garcia
Thank you all for your input, Yes random is what I need!! I checked the docs, and follow your comments, I will use both random.sample and random.shuffle,and random.choice etc. !! For this particular problem I think ramdom.shuffle() is what I need. I was not very clear or complete in my explanati

Re: pep 8 constants

2009-07-01 Thread Eric S. Johansson
Tim Chase wrote: >> I've tried it least two dozen editors and they all fail miserably >> because they're focused on keyboard use (but understandable) > [...snip...] >> I've tried a whole bunch, like I said at least a dozen. They >> all fail for first reasons such as inability to access all >> funct

Re: Adding an object to the global namespace through " f_globals" is that allowed ?

2009-07-01 Thread Terry Reedy
Stef Mientki wrote: hello, I need to add an object's name to the global namespace. The reason for this is to create an environment, where you can add some kind of math environment, where no need for Python knowledge is needed. The next statement works, but I'm not sure if it will have any drama

Re: What are the limitations of cStringIO.StringIO() ?

2009-07-01 Thread Stephen Hansen
> > >1. Anyone knows whet's the limitation on cStringIO.StringIO() objects ? >2. Could you suggest a better way to create a string that contains the >concatenation of several big files ? > > This isn't a limit in cStringIO.StringIO, but a limit on the amount of memory a process is able

Re: Multi thread reading a file

2009-07-01 Thread Stefan Behnel
Mag Gam wrote: > On Wed, Jul 1, 2009 at 12:54 AM, Gabriel Genellina wrote: >> Does the format conversion involve a significant processing time? If not, >> the total time is dominated by the I/O time (reading and writing the file) >> so it's doubtful you gain anything from multiple threads. > > The

Re: System default sys.path

2009-07-01 Thread David Lyon
On Wed, 01 Jul 2009 19:48:04 -0700, Brock Pytlik wrote: > Hi, I'm trying to find a way to get the value sys.path would have on a > particular system if python was started with an empty python path. I do > want it to include the site specific additional paths. I know I can hack > this informatio

Re: Access NtQueryInformationProces() from Python

2009-07-01 Thread Rajat
On Jun 30, 2:10 pm, Tim Golden wrote: > Dudeja, Rajat wrote: > > Hi, > > > I'm looking for a way to call the NtQueryInformationProces() and > > ReadProcessMemory() of WindowsXP from Python. > > > Can anyone direct me to some examples where they have been successfully > > called through Python? >

Re: Why re.match()?

2009-07-01 Thread Steven D'Aprano
On Thu, 02 Jul 2009 03:49:57 +, kj wrote: > In Duncan Booth > writes: >>So, for example: > > re.compile("c").match("abcdef", 2) >><_sre.SRE_Match object at 0x02C09B90> > re.compile("^c").search("abcdef", 2) > > > I find this unconvincing; with re.search alone one cou

Re: Basic question from pure beginner

2009-07-01 Thread alex23
On Jul 2, 3:47 am, Scott David Daniels wrote: > And even simpler: >      PASSWORD = "qwerty" >      MAXRETRY = 3 >      for attempt in range(MAXRETRY): >          if raw_input('Enter your password: ') == PASSWORD: >              print 'Password confirmed' >              break # this exits the for

Re: Open Source RSS Reader in Python?

2009-07-01 Thread alex23
On Jul 2, 9:18 am, Alex wrote: > I am looking for an open source RSS reader (desktop, not online) > written in Python but in vain. I am not looking for a package but a > fully functional software. > > Google: python "open source" (rss OR feeds) reader > > Any clue ? It's always worth taking a loo

Re: Why re.match()?

2009-07-01 Thread kj
In Duncan Booth writes: >So, for example: re.compile("c").match("abcdef", 2) ><_sre.SRE_Match object at 0x02C09B90> re.compile("^c").search("abcdef", 2) I find this unconvincing; with re.search alone one could simply do: >>> re.compile("^c").search("abcdef"[2:]) <_sre.S

Re: Getting input the scanf way

2009-07-01 Thread alex23
On Jul 1, 6:33 pm, "Mr.SpOOn" wrote: > I need to do some kind of interactive command line program. > > I mean: I run the program, it asks me for input, I type something and > then I get the output or other questions. > I'm not sure what is the right way to achieve this. While the simplest way wou

Re: Using Python to set desktop background image under Windows XP

2009-07-01 Thread alex23
On Jul 2, 8:02 am, "ELLINGHAUS, LANCE" wrote: > Does anyone have any code that would allow setting the desktop background > image under Windows XP? It's amazing what typing "python windows desktop" into Google will find you: http://snippets.dzone.com/posts/show/3348 Any other searches you'd li

Re: Newby Windows User

2009-07-01 Thread Xavier Ho
Double click should work. If it flashes up and goes away really quickly, then you need to run it under IDLE or some kind of python shell. Once you have Python installed, go to Start -> Run, and type in cmd to bring up the windows command line or whatever you wanna call it. Go to the folder where

Re: invoking a method from two superclasses

2009-07-01 Thread Carl Banks
On Jun 30, 9:57 pm, Mitchell L Model wrote: > [Continuing the discussion about super() and __init__] > > The documentation of super points out that good design of > diamond patterns require the methods to have the same > signature throughout the diamond. That's fine for non-mixin > classes where t

System default sys.path

2009-07-01 Thread Brock Pytlik
Hi, I'm trying to find a way to get the value sys.path would have on a particular system if python was started with an empty python path. I do want it to include the site specific additional paths. I know I can hack this information myself, but I'd rather be able to get this on demand so that i

Re: invoking a method from two superclasses

2009-07-01 Thread Mitchell L Model
[Continuing the discussion about super() and __init__] The documentation of super points out that good design of diamond patterns require the methods to have the same signature throughout the diamond. That's fine for non-mixin classes where the diamond captures different ways of handling the sa

Newby Windows User

2009-07-01 Thread rtm74
I am new to Python and use Windows XP. I would like to know how to run a python program file? -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to use sets for random selection, but the pop() method returns items in order

2009-07-01 Thread Carl Banks
On Jul 1, 7:02 pm, Paul Rubin wrote: > Carl Banks writes: > > random.shuffle() is still better when you're iterating through the > > whole list as the OP was doing. > The OP wrote: > >     I want to select, 70% random records from a List. I thougth set >     where a

Re: Trying to use sets for random selection, but the pop() method returns items in order

2009-07-01 Thread Paul Rubin
Carl Banks writes: > random.shuffle() is still better when you're iterating through the > whole list as the OP was doing. The OP wrote: I want to select, 70% random records from a List. I thougth set where a good idea so I tested this way: ... That sounds like 70% of the list, not the w

Re: Trying to use sets for random selection, but the pop() method returns items in order

2009-07-01 Thread Carl Banks
On Jul 1, 6:37 pm, Paul Rubin wrote: > Carl Banks writes: > > If you're iterating through the whole list and don't need to preserve > > the original order (as was the case here) random.shuffle() is better. > > 1. Random.sample avoids iterating through the whole list

Re: Trying to use sets for random selection, but the pop() method returns items in order

2009-07-01 Thread Paul Rubin
Carl Banks writes: > If you're iterating through the whole list and don't need to preserve > the original order (as was the case here) random.shuffle() is better. 1. Random.sample avoids iterating through the whole list when it can. 2. Say you want to choose 10 random numbers between 1 and 1

Re: Trying to use sets for random selection, but the pop() method returns items in order

2009-07-01 Thread Carl Banks
On Jul 1, 5:49 pm, Paul Rubin wrote: > Carl Banks writes: > > Instead, call random.shuffle() on the list, and iterate through that > > to get the elements in random order. > > It's better to use random.sample() than random.shuffle(). If you're iterating through the

Re: Trying to use sets for random selection, but the pop() method returns items in order

2009-07-01 Thread Steven D'Aprano
On Wed, 01 Jul 2009 17:49:21 -0700, Paul Rubin wrote: > Carl Banks writes: >> Instead, call random.shuffle() on the list, and iterate through that to >> get the elements in random order. > > It's better to use random.sample() than random.shuffle(). Why? -- Steven -- http://mail.python.org/m

Re: Multi thread reading a file

2009-07-01 Thread Mag Gam
LOL! :-) Why not. I think I will take just do it single thread for now and if performance is really that bad I can re investigate. Either way, thanks everyone for your feedback! I think I like python a lot because of the great user community and wiliness to help! On Wed, Jul 1, 2009 at 1:07 AM

Re: Why re.match()?

2009-07-01 Thread John Machin
On Jul 2, 9:50 am, MRAB wrote: > Carl Banks wrote: > > On Jul 1, 10:56 am, kj wrote: > >> For a recovering Perl-head like me it is difficult to understand > >> why Python's re module offers both match and search.  Why not just > >> use search with a beginning-of-string anchor?  I find it particul

Re: Trying to use sets for random selection, but the pop() method returns items in order

2009-07-01 Thread Paul Rubin
Carl Banks writes: > Instead, call random.shuffle() on the list, and iterate through that > to get the elements in random order. It's better to use random.sample() than random.shuffle(). -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to use sets for random selection, but the pop() method returns items in order

2009-07-01 Thread Paul Rubin
Mario Garcia writes: > Im trying to use sets for doing statistics from a data set. > I want to select, 70% random records from a List. I thougth set where > a good idea so I No that's not a good idea. When the set/dict documentation says you get the keys in an undetermined order, it doesn't mean

[ANNC] acromania-0.4

2009-07-01 Thread Lee Harr
Acromania is a word game of acronyms. This program is a computer moderator for networked games of acromania. It can connect to a channel on IRC, or start a standalone server which can be accessed much like a MUD. http://acromania.googlecode.com/ Acromania uses Twisted and SQLite. Optionally, i

Using Python to set desktop background image under Windows XP

2009-07-01 Thread ELLINGHAUS, LANCE
Does anyone have any code that would allow setting the desktop background image under Windows XP? Thank you, lance Lance Ellinghaus mailto:lance.ellingh...@hp.com -- http://mail.python.org/mailman/listinfo/python-list

Re: What are the limitations of cStringIO.StringIO() ?

2009-07-01 Thread Benjamin Kaplan
On Wed, Jul 1, 2009 at 7:48 AM, Barak, Ron wrote: > Hi, > > I think I'm up against a limitation in cStringIO.StringIO(), but could not > find any clues on the web, especially not in > http://docs.python.org/library/stringio.html. > > What I have is the following function: > >     def concatenate_fi

Re: Getting input the scanf way

2009-07-01 Thread MRAB
Mr.SpOOn wrote: Hi, I need to do some kind of interactive command line program. I mean: I run the program, it asks me for input, I type something and then I get the output or other questions. I'm not sure what is the right way to achieve this. Use raw_input() and print. -- http://mail.python.o

Re: problem installing python 2.6.2 from tarball

2009-07-01 Thread Pablo Torres N.
On Wed, Jul 1, 2009 at 16:16, Paul Simon wrote: > I have just finished going through the usual ./configure, make, etc. and now > have a load of stuff in my home directory that I think doesn't belong there. > Apparently I did the installation from my home directory (linux) and have a > directory  in

Adding an object to the global namespace through " f_globals" is that allowed ?

2009-07-01 Thread Stef Mientki
hello, I need to add an object's name to the global namespace. The reason for this is to create an environment, where you can add some kind of math environment, where no need for Python knowledge is needed. The next statement works, but I'm not sure if it will have any dramatical side effects, o

Re: getting rid of —

2009-07-01 Thread MRAB
someone wrote: Hello, how can I replace '—' sign from string? Or do split at that character? Getting unicode error if I try to do it: UnicodeDecodeError: 'ascii' codec can't decode byte 0x97 in position 1: ordinal not in range(128) Thanks, Pet script is # -*- coding: UTF-8 -*- It sounds li

Re: getting rid of —

2009-07-01 Thread Benjamin Peterson
someone googlemail.com> writes: > > Hello, > > how can I replace '—' sign from string? Or do split at that character? > Getting unicode error if I try to do it: > > UnicodeDecodeError: 'ascii' codec can't decode byte 0x97 in position > 1: ordinal not in range(128) Please paste your code. I s

Re: logging module and binary strings

2009-07-01 Thread Robert Kern
On 2009-07-01 10:02, Frank Aune wrote: Hello, snip import logging logging.basicConfig(level=logging.DEBUG) x='\xfe\x9f\xce\xc3\xa1\x00\xff\x01' x '\xfe\x9f\xce\xc3\xa1\x00\xff\x01' print x ���á� logging.info(x) Traceback (most recent call last): File "/usr/lib/python2.6/loggin

Re: Why re.match()?

2009-07-01 Thread MRAB
Carl Banks wrote: On Jul 1, 10:56 am, kj wrote: For a recovering Perl-head like me it is difficult to understand why Python's re module offers both match and search. Why not just use search with a beginning-of-string anchor? I find it particularly puzzling because I have this (possibly mistak

Suppressing Implicit Chained Exceptions (Python 3.0)

2009-07-01 Thread andrew cooke
I have some (library) code where an exception is caught and, since the underlying cause is rather obscure, a different exception is raised that more clearly explains the issue to the caller. However, when printed via format_exc(), this new exception still has the old exception attached via the me

Re: Open Source RSS Reader in Python?

2009-07-01 Thread Simon Forman
On Jul 1, 7:18 pm, Alex wrote: > I am looking for an open source RSS reader (desktop, not online) > written in Python but in vain. I am not looking for a package but a > fully functional software. > > Google: python "open source" (rss OR feeds) reader > > Any clue ? There's Canto: http://codezen.

Re: problem installing python 2.6.2 from tarball

2009-07-01 Thread ptn
Sounds like you untarred directly into your home dir. You're OK if you delete those, they are the sources, although you should do so only after uninstalling, just in case. To unistall, follow this thread from the list from a while ago: http://mail.python.org/pipermail/python-list/2004-December/29

Re: problems displaying results in ibm_db

2009-07-01 Thread ptn
On Jul 1, 3:20 pm, digz wrote: > result = ibm_db.exec_immediate( conn, 'SELECT * FROM TEST FETCH FIRST > 1 ROWS ONLY') You have the same string split into two lines, which means that what you actually have is this: result = ibm_db.exec_immediate( conn, 'SELECT * FROM TEST FETCH FIRST 1 ROWS ONLY

Re: No trees in the stdlib?

2009-07-01 Thread João Valverde
Lawrence D'Oliveiro wrote: In message , João Valverde wrote: Simple example usage case: Insert string into data structure in sorted order if it doesn't exist, else retrieve it. the_set = set( ... ) if str in the_set : ... "retrieval" case ... else : the_s

Re: Python 2.5 incompatible with Fedora Core 6 - packaging problems again

2009-07-01 Thread Melissa Powers
Hi, This may be a stretch but I came across this blog while searching for a SW Packaging Engineer. Do you know anyone in the Boston, MA area who may be interested in this position? The company is a start up with a lot of funding and this is an opportunity to define the environment and grow wi

Re: Noob

2009-07-01 Thread Chris Rebert
On Tue, Jun 30, 2009 at 11:02 AM, kaffeen wrote: > Hello all, just joined this list and am just beginning to learn Python. > Thanks to everyone for making this a great place to learn and their > contributions. > > As mentioned, I'm new to Python (but have experience with other programming > languag

Open Source RSS Reader in Python?

2009-07-01 Thread Alex
I am looking for an open source RSS reader (desktop, not online) written in Python but in vain. I am not looking for a package but a fully functional software. Google: python "open source" (rss OR feeds) reader Any clue ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python/Pygame question

2009-07-01 Thread Rhodri James
On Tue, 30 Jun 2009 19:15:24 +0100, Crip wrote: I have been experimenting with pygame. I would like to know how to go about placing an image of my creation as the background of the generated window. To where should I save the image, and what should it be saved as? Wherever will be most useful

Re: Timeout when connecting to sybase DBS

2009-07-01 Thread skip
Gil> There's no such group as python-sybase :-( http://sourceforge.net/mailarchive/forum.php?forum_name=python-sybase-misc S -- http://mail.python.org/mailman/listinfo/python-list

Re: Timeout when connecting to sybase DBS

2009-07-01 Thread skip
Gil> Are you saying, that when you trying to connect to a sybase DBS Gil> server and the DBS or the server is down, you get an error after a Gil> few seconds and not after a few minutes? Yes, though thankfully our server tends to almost always be up. Gil> Which python version are

Re: deleting certain entries in numpy array

2009-07-01 Thread Robert Kern
On 2009-07-01 09:51, Sebastian Schabe wrote: Hello everybody, I'm new to python and numpy and have a little/special problem: You will want to ask numpy questions on the numpy mailing list. http://www.scipy.org/Mailing_Lists I have an numpy array which is in fact a gray scale image mask, e

Re: A question about fill_free_list(void) function

2009-07-01 Thread Christian Heimes
Pedram schrieb: > Hello community, > I'm reading the CPython interpreter source code, > first, if you have something that I should know for better reading > this source code, I would much appreciate that :) > second, in intobject.c file, I read the following code in > fill_free_list function that I

Re: Trying to use sets for random selection, but the pop() method returns items in order

2009-07-01 Thread Ben Finney
Mario Garcia writes: > Im trying to use sets for doing statistics from a data set. > I want to select, 70% random records from a List. I thougth set where > a good idea so I > tested this way: > > c = set(range(1000)) > for d in range(1000): > print c.pop() > > I was hoping to see a print

Why re.match()?

2009-07-01 Thread kj
For a recovering Perl-head like me it is difficult to understand why Python's re module offers both match and search. Why not just use search with a beginning-of-string anchor? I find it particularly puzzling because I have this (possibly mistaken) idea that the Python design philosophy tends t

Re: logging module and binary strings

2009-07-01 Thread Peter Otten
Frank Aune wrote: import logging logging.basicConfig(level=logging.DEBUG) x='\xfe\x9f\xce\xc3\xa1\x00\xff\x01' x > '\xfe\x9f\xce\xc3\xa1\x00\xff\x01' logging.info(x) > Traceback (most recent call last): > File "/usr/lib/python2.6/logging/__init__.py", line 773, in emit

Re: Basic question from pure beginner

2009-07-01 Thread Scott David Daniels
Charles Yeomans wrote: Let me offer a bit of editing Finally, I'd remove correct_password_given from the loop test, and replace it with a break statement when the correct password is entered. password = "qwerty" correct_password_given = False attemptcount = 0 MaxAttempts = 3 while attemptc

Re: Ubigraph vs Matplotlib (dynamic plotting, event handling)

2009-07-01 Thread Che M
On Jun 30, 6:20 pm, Ala wrote: > Hello everyone, > > I intend to use python for some network graph plotting, with event > handling (clicking on network nodes, zooming in/out etc..) and so far I > have come across two good candidates which are Matplotlib and Ubigraph. > > Did anyone have any experi

Getting input the scanf way

2009-07-01 Thread Mr.SpOOn
Hi, I need to do some kind of interactive command line program. I mean: I run the program, it asks me for input, I type something and then I get the output or other questions. I'm not sure what is the right way to achieve this. Thanks, Carlo -- http://mail.python.org/mailman/listinfo/python-list

Bytes, Strings, Encoding

2009-07-01 Thread Eric Pruitt
Hello, I am working on the subprocess.Popen module for Python 2.7 and am now moving my changes over to Python 3.1 however I am having trouble with the whole byte situation and I can't quite seem to understand how to go back and forth between bytes and strings. I am also looking for the Python 3k e

What are the limitations of cStringIO.StringIO() ?

2009-07-01 Thread Barak, Ron
Hi, I think I'm up against a limitation in cStringIO.StringIO(), but could not find any clues on the web, especially not in http://docs.python.org/library/stringio.html. What I have is the following function: def concatenate_files(self,filename_array): import types f = cSt

Re: string character count

2009-07-01 Thread Jean-Michel Pichavant
MRAB 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 to see what method others would use - helps me learn. I gu

Re: Basic question from pure beginner

2009-07-01 Thread Charles Yeomans
Let me offer a bit of editing. First, using the condition count != 3 is perhaps risky. A mistake or a change in logic in the loop body might result in an infinite loop. So instead I suggest while count < 3... Second, I'd suggest storing the value 3 in a variable with a name that descri

Re: Multi thread reading a file

2009-07-01 Thread Mag Gam
Thanks for the response Gabriel. On Wed, Jul 1, 2009 at 12:54 AM, Gabriel Genellina wrote: > En Tue, 30 Jun 2009 22:52:18 -0300, Mag Gam escribió: > >> I am very new to python and I am in the process of loading a very >> large compressed csv file into another format.  I was wondering if I >> ca

Re: No trees in the stdlib?

2009-07-01 Thread MRAB
Lawrence D'Oliveiro wrote: In message , João Valverde wrote: Simple example usage case: Insert string into data structure in sorted order if it doesn't exist, else retrieve it. the_set = set( ... ) if str in the_set : ... "retrieval" case ... else : the_set.add(s

Re: No trees in the stdlib?

2009-07-01 Thread Tim Golden
Lawrence D'Oliveiro wrote: Want sorted order? sorted(tuple(the_set)) Not sure why you want the tuple () there, but you probably knew that... TJG -- http://mail.python.org/mailman/listinfo/python-list

Re: Basic question from pure beginner

2009-07-01 Thread MRAB
sato.ph...@gmail.com wrote: I have been going through some Python Programming exercises while following the MIT OpenCourseWare Intro to CS syllabus and am having some trouble with the first "If" exercise listed on this page: http://en.wikibooks.org/wiki/Python_Programming/Conditional_Statements#

logging module and binary strings

2009-07-01 Thread Frank Aune
Hello, snip >>> import logging >>> logging.basicConfig(level=logging.DEBUG) >>> x='\xfe\x9f\xce\xc3\xa1\x00\xff\x01' >>> x '\xfe\x9f\xce\xc3\xa1\x00\xff\x01' >>> print x ���á� >>> logging.info(x) Traceback (most recent call last): File "/usr/lib/python2.6/logging/__init__.py", line 773

Re: Making code run in both source tree and installation path

2009-07-01 Thread Robert Kern
On 2009-07-01 01:04, Carl Banks wrote: On Jun 29, 9:20 am, Javier Collado wrote: I've seen different approaches: - distutils trick in setup.py to modify the installed script (i.e. changing a global variable value) so that it has a reference to the data files location. One of my biggest compl

Re: invoking a method from two superclasses

2009-07-01 Thread Michele Simionato
On Jul 1, 2:34 am, Mitchell L Model wrote: > I suspect we should have a Multiple Inheritance HOWTO, though details and > recommendations would be controversial. I've accumulated lots of abstract > examples along the lines of my question, using multiple inheritance both to > create combination clas

getting rid of —

2009-07-01 Thread someone
Hello, how can I replace '—' sign from string? Or do split at that character? Getting unicode error if I try to do it: UnicodeDecodeError: 'ascii' codec can't decode byte 0x97 in position 1: ordinal not in range(128) Thanks, Pet script is # -*- coding: UTF-8 -*- -- http://mail.python.org/mail

Re: Idioms and Anti-Idioms Question

2009-07-01 Thread Lawrence D'Oliveiro
In message , J. Cliff Dyer wrote: > If the lines got separated, a leading + could disappear into its line > without any errors showing up. A trailing + would raise a syntax error. Unless, of course, it was moved onto the previous line as part of whatever caused the separation of the lines. How

Re: Multi thread reading a file

2009-07-01 Thread Lawrence D'Oliveiro
In message , Mag Gam wrote: > I am very new to python and I am in the process of loading a very > large compressed csv file into another format. I was wondering if I > can do this in a multi thread approach. Why bother? -- http://mail.python.org/mailman/listinfo/python-list

Re: Direct interaction with subprocess - the curse of blocking I/O

2009-07-01 Thread ryles
On Jun 29, 5:43 pm, Scott David Daniels wrote: > and I personally wouldn't have it any other way. Simulating a shell > with hooks on its I/O should be so complicated that a "script kiddie" > has trouble writing a Trojan. +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to use sets for random selection, but the pop() method returns items in order

2009-07-01 Thread Mensanator
On Jul 1, 5:29 pm, Mensanator wrote: > On Jul 1, 4:34 pm, Mario Garcia wrote: > > > > > > > Im trying to use sets for doing statistics from a data set. > > I want to select, 70% random records from a List. I thougth set where > > a good idea so I > > tested this way: > > > c = set(range(1000)) >

Re: Problem with uuid package when embedding a python interpreter

2009-07-01 Thread Aahz
In article <7d5cfbf0-38d5-4505-a93a-f321d0da7...@c36g2000yqn.googlegroups.com>, =?ISO-8859-1?Q?J=E9r=F4me_Fuselier?= wrote: > >I've tried to import a script in an embedded python intrepreter but >this script fails when it imports the uuid module. I have a >segmentation fault in Py_Finalize(). Yo

Re: Why re.match()?

2009-07-01 Thread Carl Banks
On Jul 1, 10:56 am, kj wrote: > For a recovering Perl-head like me it is difficult to understand > why Python's re module offers both match and search.  Why not just > use search with a beginning-of-string anchor?  I find it particularly > puzzling because I have this (possibly mistaken) idea that

Re: Trying to use sets for random selection, but the pop() method returns items in order

2009-07-01 Thread Mensanator
On Jul 1, 4:34 pm, Mario Garcia wrote: > Im trying to use sets for doing statistics from a data set. > I want to select, 70% random records from a List. I thougth set where > a good idea so I > tested this way: > > c = set(range(1000)) > for d in range(1000): >      print c.pop() > > I was hoping

Re: Trying to use sets for random selection, but the pop() method returns items in order

2009-07-01 Thread Carl Banks
On Jul 1, 2:34 pm, Mario Garcia wrote: > Im trying to use sets for doing statistics from a data set. > I want to select, 70% random records from a List. I thougth set where > a good idea so I > tested this way: > > c = set(range(1000)) > for d in range(1000): >      print c.pop() > > I was hoping

Trying to use sets for random selection, but the pop() method returns items in order

2009-07-01 Thread Mario Garcia
Im trying to use sets for doing statistics from a data set. I want to select, 70% random records from a List. I thougth set where a good idea so I tested this way: c = set(range(1000)) for d in range(1000): print c.pop() I was hoping to see a print out of random selected numbers from 1 to 10

problem installing python 2.6.2 from tarball

2009-07-01 Thread Paul Simon
I have just finished going through the usual ./configure, make, etc. and now have a load of stuff in my home directory that I think doesn't belong there. Apparently I did the installation from my home directory (linux) and have a directory in my home directory "Python2.6.2" with subdirectories

problems displaying results in ibm_db

2009-07-01 Thread digz
This simple db connectivity and select test program works in the interactive mode >>> import ibm_db >>> conn = ibm_db.connect( 'DATABASE', 'user', 'passwd') >>> result = ibm_db.exec_immediate( conn, 'SELECT * FROM TEST FETCH FIRST 1 >>> ROWS ONLY') >>> row = ibm_db.fetch_tuple( result ) >>> for r

Re: deleting certain entries in numpy array

2009-07-01 Thread Ben Finney
Sebastian Schabe writes: > I want to avoid a for loop (if possible!!!) cause I think (but don't > know) numpy array are handled in another way. Yes, Numpy arrays can be indexed logically by a boolean array. > I think numpy.delete is the right function for discarding the values, > but I don't kn

Re: Direct interaction with subprocess - the curse of blocking I/O

2009-07-01 Thread spillz
On Jun 29, 3:15 pm, Pascal Chambon wrote: > Hello everyone > > I've had real issues with subprocesses recently : from a python script, > on windows, I wanted to "give control" to a command line utility, i.e > forward user in put to it and display its output on console. It seems > simple, but I ran

Re: Why re.match()?

2009-07-01 Thread Duncan Booth
kj wrote: > > > For a recovering Perl-head like me it is difficult to understand > why Python's re module offers both match and search. Why not just > use search with a beginning-of-string anchor? I find it particularly > puzzling because I have this (possibly mistaken) idea that the > Python

Re: Basic question from pure beginner

2009-07-01 Thread Bruno Desthuilliers
Scott David Daniels a écrit : (snip) And even simpler: PASSWORD = "qwerty" MAXRETRY = 3 for attempt in range(MAXRETRY): if raw_input('Enter your password: ') == PASSWORD: print 'Password confirmed' break # this exits the for loop print 'Access

Re: Basic question from pure beginner

2009-07-01 Thread Bruno Desthuilliers
Charles Yeomans a écrit : Please don't top-post (not corrected) Let me offer a bit of editing. First, using the condition count != 3 is perhaps risky. A mistake or a change in logic in the loop body might result in an infinite loop. So instead I suggest while count < 3... Second, I'd su

Re: Getting input the scanf way

2009-07-01 Thread Bruno Desthuilliers
Mr.SpOOn a écrit : Hi, I need to do some kind of interactive command line program. I mean: I run the program, it asks me for input, I type something and then I get the output or other questions. I'm not sure what is the right way to achieve this. Simplest : use raw_input() Friendlier (at least

a little wsgi framework

2009-07-01 Thread timmyt
i'm interested in getting opinions on a small wsgi framework i assembled from webob, sqlalchemy, genshi, and various code fragments i found on the inter-tubes here is the interesting glue - any comments / suggestions would be much appreciated -- the wsgi app -- def

Re: It's ...

2009-07-01 Thread J. Cliff Dyer
On Tue, 2009-06-30 at 13:24 -0700, Beni Cherniavsky wrote: > On Jun 24, 11:40 pm, "J. Cliff Dyer" wrote: > > Also note that you can iterate over a file several times: > > > > f = open('foo.txt') > > for line in f: > > print line[0] # prints the first character of every line > > for line in f:

Re: Multi thread reading a file

2009-07-01 Thread Scott David Daniels
Gabriel Genellina wrote: ... def convert(in_queue, out_queue): while True: row = in_queue.get() if row is None: break # ... convert row out_queue.put(converted_line) These loops work well with the two-argument version of iter, which is easy to forget, but quite useful to have

  1   2   >