The '-c' CLI option removes just the command str.

2020-05-05 Thread Simon Forman via Python-list
Is this anything? When you run a python command from the shell to just print the command line args you get this: $ python -c "import sys; print(sys.argv)" ['-c'] But I would expect one of these: Either the '-c' option consumes both args: $ python -c "import sys; print(sys.argv)"

A curious bit of code...

2014-02-14 Thread Simon Forman
(Apologies if this results in a double-post.) On Friday, February 14, 2014 1:01:48 PM UTC-8, Mark Lawrence wrote: [snip] > > Pleased to have you on board, as I'm know that Terry Reedy et al can do > with a helping hand. > > But please note you appear to be using google groups, hence the double

Re: A curious bit of code...

2014-02-14 Thread Simon Forman
On Friday, February 14, 2014 1:01:48 PM UTC-8, Mark Lawrence wrote: [snip] > > Pleased to have you on board, as I'm know that Terry Reedy et al can do > with a helping hand. > > But please note you appear to be using google groups, hence the double > line spacing above and trying to reply to pa

Re: testing if a list contains a sublist

2011-08-20 Thread Simon Forman
On Mon, Aug 15, 2011 at 4:26 PM, Johannes wrote: > hi list, > what is the best way to check if a given list (lets call it l1) is > totally contained in a second list (l2)? > > for example: > l1 = [1,2], l2 = [1,2,3,4,5] -> l1 is contained in l2 > l1 = [1,2,2,], l2 = [1,2,3,4,5] -> l1 is not contai

Re: parallel class structures for AST-based objects

2009-11-22 Thread Simon Forman
On Sun, Nov 22, 2009 at 4:50 AM, Diez B. Roggisch wrote: > Steve Howell schrieb: >> >> On Nov 21, 4:07 pm, MRAB wrote: >>> >>> I don't see the point of EvalNode and PrettyPrintNode. Why don't you >>> just give Integer, Sum and Product 'eval' and 'pprint' methods? >> >> That's a good question, and

Re: make two tables having same orders in both column and row names

2009-11-19 Thread Simon Forman
On Wed, Nov 18, 2009 at 3:57 PM, Ping-Hsun Hsieh wrote: > Hi, > > I would like to compare values in two table with same column and row names, > but with different orders in column and row names. > For example, table_A in a file looks like the follows: > AA100   AA109   AA101   AA103   AA102 > BB1

Re: using struct module on a file

2009-11-18 Thread Simon Forman
On Wed, Nov 18, 2009 at 11:42 AM, Ulrich Eckhardt wrote: > Hia! > > I need to read a file containing packed "binary" data. For that, I find the > struct module pretty convenient. What I always need to do is reading a chunk > of data from the file (either using calcsize() or a struct.Struct instanc

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

2009-11-18 Thread Simon Forman
On Wed, Nov 18, 2009 at 4:15 AM, Steve Howell wrote: > On the topic of "switch" statements and even-more-concise-then-we-have- > already if/elif/else/end constructs, I have to say that Python does > occasionally force you to write code like the code below.  Maybe > "force" is too strong a word, bu

Re: Anything equivalent to cassert in C++?

2009-11-17 Thread Simon Forman
On Tue, Nov 17, 2009 at 4:19 PM, Peng Yu wrote: > There are some assertion code (testing if a condition is false, if it > is false, raise an Error object) in my python, which is useful when I > test my package.  But such case would never occur when in the produce > code. If I keep them in if state

Re: Python & Go

2009-11-15 Thread Simon Forman
On Sat, Nov 14, 2009 at 5:10 PM, Terry Reedy wrote: > Paul Rubin wrote: > >> Mark Chu-Carroll has a new post about Go: >> >> >>  http://scienceblogs.com/goodmath/2009/11/the_go_i_forgot_concurrency_an.php > > In a couple of minutes, I wrote his toy prime filter example in Python, > mostly from the

Re: Calendar Stuff

2009-11-10 Thread Simon Forman
On Tue, Nov 10, 2009 at 12:53 PM, Victor Subervi wrote: > Hi; > I have the following code: > > import calendar, datetime > > def cal(): >   ... >   myCal = calendar.Calendar(calendar.SUNDAY) >   today = datetime.date.today() >   day = today.day >   mo = today.month >   yr = today.year > #  month =

Re: NEWB problem with urllib2

2009-11-09 Thread Simon Forman
On Mon, Nov 9, 2009 at 6:29 PM, Penn wrote: > I just installed PyDev into Eclipse using the 'update' method and did > the standard installation.  I allowed it to Auto Configure itself and > ran a "Hello World" module to make sure I was in the ballpark. > > I got an starting module up and have run

Re: Serious Privileges Problem: Please Help

2009-11-09 Thread Simon Forman
On Mon, Nov 9, 2009 at 12:44 PM, Victor Subervi wrote: > Did you give up on me? > V > Please don't top-post. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why do you use python?

2009-11-05 Thread Simon Forman
On Sat, Oct 31, 2009 at 2:11 AM, sk wrote: > What would be your answer if this question is asked to you in an > interview? > > a modified version might be: > "Where would you use python over C/C++/Java?" > > (because my resume says I know C/C++/Java)? Mark Miller has some adages posted on his ho

Re: disutils, project structure & developing - n00b question

2009-10-29 Thread Simon Forman
On Thu, Oct 29, 2009 at 3:45 PM, Simon Forman wrote: > In order for "from pymlb import fetcher" no work you must make the s/no/to/ D'oh! -- http://mail.python.org/mailman/listinfo/python-list

Re: disutils, project structure & developing - n00b question

2009-10-29 Thread Simon Forman
On Thu, Oct 29, 2009 at 2:42 PM, Wells wrote: > So I have my project partitioned like so: > > ./setup.py > ./pymlb/ > ./pymlb/fetcher.py > ./demos > ./demos/demo.py > > In demo.py I have: > > from pymlb import fetcher > > However, it fails b/c pymlb is up a folder. It's also NOT installed as > a m

Re: What IDE has good git and python support?

2009-10-28 Thread Simon Forman
On Tue, Oct 27, 2009 at 11:56 AM, Aweks wrote: > what do you use? I use IDLE for python and Bash for GIT. Regards, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: handling PAMIE and lxml

2009-10-26 Thread Simon Forman
On Mon, Oct 26, 2009 at 3:05 AM, elca wrote: > > Hello, > i was open anther new thread ,old thread is too long. Too long for what? > first of all,i really appreciate other many people's help in this newsgroup. > im making webscraper now. > but still problem with my script source. > http://elca.p

Re: Python 2.6 Deprecation Warnings with __new__ — Can someone explain why?

2009-10-26 Thread Simon Forman
On Mon, Oct 26, 2009 at 12:04 AM, rh0dium wrote: [snip] > > > Now the real question I have on this is scalability.  The real What you're describing isn't "scalability". It could be called "extensibility". > advantage to using *args and **kwargs is that down the road (through > inheritance/polym

Re: python web service or Apache?

2009-10-26 Thread Simon Forman
On Mon, Oct 26, 2009 at 10:00 AM, Peng Yu wrote: > On Sun, Oct 25, 2009 at 11:09 PM, Simon Forman wrote: >> On Sun, Oct 25, 2009 at 4:47 PM, Peng Yu wrote: >>> Although, python can be used to provide web service. The following >>> webpage also mentioned, "Apac

Re: python web service or Apache?

2009-10-25 Thread Simon Forman
On Sun, Oct 25, 2009 at 4:47 PM, Peng Yu wrote: > Although, python can be used to provide web service. The following > webpage also mentioned, "Apache the best and most widely used web > server on the Internet today, check it out. If you want to run your > own web server this is the one to get, yo

Re: Simple audio

2009-10-20 Thread Simon Forman
On Tue, Oct 20, 2009 at 4:04 PM, Peter Chant wrote: > What are recommendations for simple audio playback?  I want to play back on > linux (Slackware), which uses alsa.  There seem to be many ways - but some > are a couple of years old and won't compile, like pymedia, or seem not > widely used and

Re: Iterators

2009-10-16 Thread Simon Forman
On Fri, Oct 16, 2009 at 8:22 AM, Duncan Booth wrote: > Chris Rebert wrote: > >> Essentially, file iterators are dumb and don't keep track of where in >> the file the next line starts, instead relying on their associated >> file object to keep track of the current position in the file; the >> iter

Re: a=[1,2,3,4].reverse() - why "a" is None?

2009-10-13 Thread Simon Forman
On Mon, Oct 12, 2009 at 4:44 AM, Nadav Chernin wrote: > >        Chris Withers wrote: > >        ...becauase you were looking for: > >        reversed([1,2,3,4]) > > OK, but my question is generic. Why when I use object's function that > changed values of the object, I can't to get value of it on

Re: Persistent Distributed Objects

2009-10-11 Thread Simon Forman
On Sun, Oct 11, 2009 at 12:46 PM, John Haggerty wrote: > Does pyro work inside of stackless? I have no idea, but you wouldn't need both. Only one or the other. ~Simon > On Sat, Oct 10, 2009 at 9:54 AM, Simon Forman wrote: >> >> On Fri, Oct 9, 2009 at 1:11 AM, John Hag

Re: Why ELIF?

2009-10-11 Thread Simon Forman
On Sun, Oct 11, 2009 at 2:15 PM, TerryP wrote: > On Oct 11, 3:42 pm, Esmail wrote: >> cool .. I hadn't seen that. Not working quite at the 'pythonic' level yet >> I am not sure I think it's more readable that the if statement. Also, curious >> if the dictionary approach is more efficient. >> > >

Re: Persistent Distributed Objects

2009-10-10 Thread Simon Forman
On Fri, Oct 9, 2009 at 1:11 AM, John Haggerty wrote: > I am interested in seeing how it would be possible in python to have > persistent objects (basically be able to save objects midway through a > computation, etc) and do so across multiple computers. > > Something that would allow for memory, d

Re: Is there a better way to code variable number of return arguments?

2009-10-08 Thread Simon Forman
On Thu, Oct 8, 2009 at 7:14 PM, Dr. Phillip M. Feldman wrote: > > I'm amazed that this works.  I had not realized that > > x,y= [3,4] > > is equivalent to > > x= 3; y= 4 > > Python is rather clever. > > Thanks! > Python is very clever: >>> (a, b), c = (1, 2), 3 >>> a, b, c (1, 2, 3) :D -- http

Re: Is there a better way to code variable number of return arguments?

2009-10-08 Thread Simon Forman
On Thu, Oct 8, 2009 at 12:41 PM, Dr. Phillip M. Feldman wrote: > > I currently have a function that uses a list internally but then returns the > list items as separate return > values as follows: > > if len(result)==1: return result[0] > if len(result)==2: return result[0], result[1] > > (and so

Re: Cashing in PythonWin name space?... seems unexpected to me

2009-10-08 Thread Simon Forman
On Thu, Oct 8, 2009 at 9:47 AM, bsneddon wrote: > I saw an issue  on winXP  box not connected to internet yesterday, > where i was running > a script in the interactive window on PythonWin .   I would modify the > script save and > import and was still running the old version.  I did that several

Re: threading module, call thread.interrupt_main()

2009-10-08 Thread Simon Forman
2009/10/7 找尋自己的一片天 : > Sorry to ask, but i don't know how to solve it. > > I try to call thread.interrupt_main() function in my child thread's run method > which is inherit threading.Thread class. > > But it didn't work, does anyone know why? > > Thanks a lot!! > "it didn't work" i

Re: del an imported Class at EOF... why?

2009-10-08 Thread Simon Forman
On Thu, Oct 8, 2009 at 1:42 AM, Terry Reedy wrote: > Hans Mulder wrote: > >> Errrhm, no.  He is not deleting the PyQt4 module from sys.modules; >> he's only deleting the name QtGui from his own namespace.  Next >> time Python comes across >> >>    from PyQt4 import QtGui >> >> , it finds that the

Re: Object Relational Mappers are evil (a meditation)

2009-10-06 Thread Simon Forman
On Tue, Oct 6, 2009 at 2:00 AM, Carl Banks wrote: > On Oct 5, 7:25 am, Aaron Watters wrote: >> This is a bit off topic except that many Python >> programmers seem to be allergic to typing SQL. >> >> RESOLVED:  Using ORMs leads lazy programmers >> to make bad database designs.  It's better to >> c

Re: Object Relational Mappers are evil (a meditation)

2009-10-05 Thread Simon Forman
On Mon, Oct 5, 2009 at 11:14 PM, Paul Rubin wrote: > Steve Holden writes: >> It seems to me that the biggest sin in databases is a failure to use >> rigorous design techniques. If somebody doesn't understand relational >> theory > > Where does one find out about this

Re: Walking an object/reference graph

2009-10-05 Thread Simon Forman
On Mon, Oct 5, 2009 at 3:59 AM, Austin Bingham wrote: > I'm looking for the proper way to "walk" a graph of python objects. My > specific task is to find all objects of a given type that are referred > to (transitively) by some starting object. My approach has been to > loop through the object's a

Re: creating class objects inside methods

2009-10-04 Thread Simon Forman
On Sun, Oct 4, 2009 at 2:44 PM, horos11 wrote: > >> >> > Thanks for the info, but a couple of points: >> >> >     1. it wasn't meant to be production code, simply a way to teach >> > python. >> >> Speaking as someone who does teach Python, "Ew, no!"  If you start by >> teaching people bad habits,

Re: creating class objects inside methods

2009-10-04 Thread Simon Forman
On Sun, Oct 4, 2009 at 1:12 AM, horos11 wrote: > >> >>> a >> >> <__main__.Myclass instance at 0x95cd3ec b >> >> <__main__.Myclass instance at 0x95cd5ac> >> >> What's the problem? > > Like I said, the code was a sample of what I was trying to do, not the > entire thing.. I just wanted to see if

Re: Is pythonic version of scanf() or sscanf() planned?

2009-10-04 Thread Simon Forman
On Sun, Oct 4, 2009 at 5:29 AM, Martien Verbruggen wrote: > On Sun, 4 Oct 2009 01:17:18 + (UTC), >        Grant Edwards wrote: >> On 2009-10-03, ryniek90 wrote: >> >>> So, whether it is or has been planned the core Python >>> implementation of *scanf()* ? >> >> One of the fist things I remem

Re: defaults for function arguments bound only once(??)

2009-10-04 Thread Simon Forman
On Sun, Oct 4, 2009 at 2:29 AM, horos11 wrote: > All, > > Another one, this time a bit shorter. > > It looks like defaults for arguments are only bound once, and every > subsequent call reuses the first reference created. Hence the > following will print '[10,2]' instead of the expected '[1,2]'. >

Re: creating class objects inside methods

2009-10-03 Thread Simon Forman
On Sat, Oct 3, 2009 at 11:32 PM, horos11 wrote: > All, > > I've got a strange one.. > > I'm trying to create a class object inside another class object by > using the code template below (note.. this isn't the exact code.. I'm > having difficulty reproducing it without posting the whole thing) > >

Re: Opinions, please, on PEP 8 and local, 3rd party imports

2009-10-02 Thread Simon Forman
On Fri, Oct 2, 2009 at 3:50 PM, Philip Semanchuk wrote: > Hi all, > Our project uses some libraries that were written by 3rd parties (i.e. not > us). These libraries fit into a single Python file and live in our source > tree alongside other modules we've written. When our app is distributed, > th

Re: Simple Python struct issue

2009-10-02 Thread Simon Forman
On Fri, Oct 2, 2009 at 12:35 PM, Carlo DiCelico wrote: > On Oct 2, 12:15 pm, Simon Forman wrote: >> On Fri, Oct 2, 2009 at 12:07 PM, Carlo DiCelico >> wrote: >> > I saw an article on O'Reilly about using NumPy and Dislin to analyze >> > and visualize WAV

Re: Simple Python struct issue

2009-10-02 Thread Simon Forman
On Fri, Oct 2, 2009 at 12:07 PM, Carlo DiCelico wrote: > I saw an article on O'Reilly about using NumPy and Dislin to analyze > and visualize WAV files. It's a really fantastic article but was a > little out of date. I updated the script to work with the newer > modules &etc but am still having tr

Re: emptying a list

2009-10-01 Thread Simon Forman
On Thu, Oct 1, 2009 at 11:30 AM, lallous wrote: > Hello > > What is faster when clearing a list? > > del L[:] > > or > > L = [] > > -- > Elias > -- > http://mail.python.org/mailman/listinfo/python-list > The first form actually clears the list, the second for just re-binds the name 'L' to a new,

Re: hii

2009-10-01 Thread Simon Forman
On Thu, Oct 1, 2009 at 7:55 AM, padmapriya sekaran wrote: > I have a problem in using interp from numpy for which i need 3 array. > my first array is > x = scipy.linspace(0.009,0.53,100) > > and the other two array should be read from my file with 100x2 dimension > (file1_lines) but it is read as

Re: iterate over list while changing it

2009-10-01 Thread Simon Forman
On Wed, Sep 30, 2009 at 11:19 PM, Daniel Stutzbach wrote: > On Thu, Sep 24, 2009 at 3:32 PM, Torsten Mohr wrote: >> >> a = [1, 2, 3, 4, 5, 6] >> >> for i, x in enumerate(a): >>    if x == 3: >>        a.pop(i) >>        continue >> >>    if x == 4: >>        a.push(88) >> >>    print "i", i, "x",

Re: How different are a generator's send and next methods

2009-10-01 Thread Simon Forman
On Wed, Sep 30, 2009 at 4:24 PM, Andrey Fedorov wrote: > As far as I can tell, a generator's .next() is equivalent to .send(None). Is > this true? They are equivalent AFAIK. > If so, [why] aren't they unified in a method with a single argument which > defaults > to None? > - Andrey next() pred

Re: Split string but ignore quotes

2009-09-29 Thread Simon Forman
On Tue, Sep 29, 2009 at 11:11 AM, Scooter wrote: > I'm attempting to reformat an apache log file that was written with a > custom output format. I'm attempting to get it to w3c format using a > python script. The problem I'm having is the field-to-field matching. > In my python code I'm using spli

Re: Repeated output when logging exceptions

2009-09-28 Thread Simon Forman
On Mon, Sep 28, 2009 at 4:38 PM, John Gordon wrote: > In <6bce12c3-f2d9-450c-89ee-afa4f21d5...@h30g2000vbr.googlegroups.com> Vinay > Sajip writes: > >> The logging package allows you to add tracebacks to your logs by using >> the exception() method, which logs an ERROR with a traceback and is >>

Re: Multidimensional arrays/lists

2009-09-28 Thread Simon Forman
On Mon, Sep 28, 2009 at 3:27 PM, Ethan Furman wrote: > Simon Forman wrote: >> >> On Sun, Sep 27, 2009 at 12:40 PM, Someone Something >> wrote: >> >>> I'm trying to write a little tic-tac-toe program I need a array/list such >>> that I can represe

Re: Multidimensional arrays/lists

2009-09-27 Thread Simon Forman
On Sun, Sep 27, 2009 at 12:40 PM, Someone Something wrote: > I'm trying to write a little tic-tac-toe program I need a array/list such > that I can represent the tic tac toe board with an x axis and y axis and i > can access each square to find out whether there is an X or an O. I have > absolutel

Re: Is there a method (similar to str() method in R) that can print the data structure in python?

2009-09-27 Thread Simon Forman
On Sun, Sep 27, 2009 at 12:14 PM, Peng Yu wrote: > On Sat, Sep 26, 2009 at 2:05 PM, Robert Kern wrote: >> On 2009-09-26 09:32 AM, Peng Yu wrote: >>> >>> Hi, >>> >>> I am looking for a method in python that is similar to the function >>> str() in R, if you are familiar with R, >>> >>> If you have

Re: Detecting changes to a dict

2009-09-27 Thread Simon Forman
On Sun, Sep 27, 2009 at 5:36 AM, Steven D'Aprano wrote: > I'm pretty sure the answer to this is No, but I thought I'd ask just in > case... > > Is there a fast way to see that a dict has been modified? I don't care > what the modifications are, I just want to know if it has been changed, > where "

Re: Business issues regarding adapting Python

2009-09-27 Thread Simon Forman
On Sun, Sep 27, 2009 at 10:48 AM, Nash wrote: > On Sep 27, 4:13 pm, "Martin P. Hellwig" > wrote: >> Nash wrote: >> >> >> I think normal market rules will apply to Pakistan too, if your desired >> trade has not the quantity you wish, the price per item should get >> higher. Net result should be t

Re: flow control and nested loops

2009-09-25 Thread Simon Forman
On Fri, Sep 25, 2009 at 3:01 PM, kj wrote: > > > In Perl, one can label loops for finer flow control.  For example: > > X: for my $x (@X) { >  Y: for my $y (@Y) { >    for my $z (@Z) { >      next X if test1($x, $y, $z); >      next Y if test2($x, $y, $z); >      frobnicate($x, $y, $z); >    } >  

Re: Most "active" coroutine library project?

2009-09-25 Thread Simon Forman
On Fri, Sep 25, 2009 at 2:07 PM, Jason Tackaberry wrote: > On Fri, 2009-09-25 at 15:42 +, Grant Edwards wrote: >> You can't call a function that yields control back to the other >> coroutine(s).  By jumping through some hoops you can get the >> same effect, but it's not very intuitive and it s

Re: Most "active" coroutine library project?

2009-09-25 Thread Simon Forman
On Fri, Sep 25, 2009 at 11:42 AM, Grant Edwards wrote: > On 2009-09-25, Piet van Oostrum wrote: >>> exar...@twistedmatrix.com (e) wrote: >> >>>e> I specifically left out all "yield" statements in my version, since that's >>>e> exactly the point here. :)  With "real" coroutines, they're not ne

Re: Regex trouble

2009-09-24 Thread Simon Forman
On Thu, Sep 24, 2009 at 6:31 PM, Rhodri James wrote: > On Thu, 24 Sep 2009 19:45:37 +0100, Simon Forman > wrote: > >> FWIW this problem is too simple (IMHO) for regular expressions. >> Simply carve off the first three digits and check against sets of the >> pr

Re: iterate over list while changing it

2009-09-24 Thread Simon Forman
On Thu, Sep 24, 2009 at 4:32 PM, Torsten Mohr wrote: > Hello, > > a = [1, 2, 3, 4, 5, 6] > > for i, x in enumerate(a): >    if x == 3: >        a.pop(i) >        continue > >    if x == 4: >        a.push(88) > >    print "i", i, "x", x > > I'd like to iterate over a list and change that list whil

Re: Regex trouble

2009-09-24 Thread Simon Forman
On Thu, Sep 24, 2009 at 10:43 AM, Support Desk wrote: > I am trying to loop over a dictionary  of phone numbers and using a python > regex to determine if they are long distance or local and then adding them > to their appropriate dictionary, My regex doesn't appear to be working > though. "doesn

Re: arrays in python

2009-09-23 Thread Simon Forman
On Wed, Sep 23, 2009 at 10:03 PM, AggieDan04 wrote: > On Sep 23, 3:02 pm, Simon Forman wrote: >> On Wed, Sep 23, 2009 at 1:14 PM, Rudolf wrote: >> > Can someone tell me how to allocate single and multidimensional arrays >> > in python. I looked online and it

Re: Searching Dictionary

2009-09-23 Thread Simon Forman
On Wed, Sep 23, 2009 at 2:31 PM, Support Desk wrote: > > i am trying to search a large Python dictionary for a matching value. The > results would need to be structured into a new dictionary with the same > structure. Thanks. > > The structure is like this > > { Key : [{'item':value,'item2':value,

Re: Most "active" coroutine library project?

2009-09-23 Thread Simon Forman
On Wed, Sep 23, 2009 at 2:05 PM, wrote: > On 05:00 pm, sajmik...@gmail.com wrote: >> >> On Sun, Aug 23, 2009 at 11:02 AM, Phillip B Oldham >> wrote: >>> >>> I've been taking a look at the multitude of coroutine libraries >>> available for Python, but from the looks of the projects they all seem

Re: arrays in python

2009-09-23 Thread Simon Forman
On Wed, Sep 23, 2009 at 1:22 PM, Donn wrote: > On Wednesday 23 September 2009 19:14:20 Rudolf wrote: >> I want to allocate an array and then populate it >> using a for loop. > You don't need to allocate anything, just use the list or dictionary types. > > l=[] #empty list > for x in range(1,50

Re: arrays in python

2009-09-23 Thread Simon Forman
On Wed, Sep 23, 2009 at 1:14 PM, Rudolf wrote: > Can someone tell me how to allocate single and multidimensional arrays > in python. I looked online and it says to do the following x = > ['1','2','3','4'] > > However, I want a much larger array like a 100 elements, so I cant > possibly do that. I

Re: Most "active" coroutine library project?

2009-09-23 Thread Simon Forman
On Sun, Aug 23, 2009 at 11:02 AM, Phillip B Oldham wrote: > I've been taking a look at the multitude of coroutine libraries > available for Python, but from the looks of the projects they all seem > to be rather "quiet". I'd like to pick one up to use on a current > project but can't deduce which

Re: Searching a large dictionary

2009-09-22 Thread Simon Forman
On Tue, Sep 22, 2009 at 6:30 PM, Support Desk wrote: > Chris,  Yes that is the correct syntax, thanks > Okay, but correct syntax of what? Help us help you. > On Tue, Sep 22, 2009 at 5:22 PM, Chris Rebert wrote: >> >> On Tue, Sep 22, 2009 at 2:50 PM, Support Desk >> wrote: >> > I need help se

Re: Searching a large dictionary

2009-09-22 Thread Simon Forman
On Tue, Sep 22, 2009 at 5:50 PM, Support Desk wrote: > I need help searching a large python dictionary. The dictionary is setup > like so > > Key[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}] > > Key2[{'item':value,

Re: Read header and data from a binary file

2009-09-22 Thread Simon Forman
On Tue, Sep 22, 2009 at 4:30 PM, Jose Rafael Pacheco wrote: > Hello, > > I want to read from a binary file called myaudio.dat > Then I've tried the next code: > > import struct > name = "myaudio.dat" > f = open(name,'rb') > f.seek(0) Don't bother to seek(0) on a file you just opened. > chain = "

Re: Dynamic Form

2009-09-22 Thread Simon Forman
On Tue, Sep 22, 2009 at 10:46 AM, Victor Subervi wrote: > Hi; > I have a dynamic form in which I do the following: > 1) Request two fields (company name, number of entries). That is sent back > to the form. > 2) If the two fields are not None, the form requests other data. That, too, > is sent bac

Re: How to get the minimum number that can be represented?

2009-09-20 Thread Simon Forman
On Sep 20, 11:23 am, Peng Yu wrote: > On Sun, Sep 20, 2009 at 9:37 AM, Grant Edwards > wrote: > > On 2009-09-20, Peng Yu wrote: > > >> Suppose I want to define a function that return the minimum number > >> that can be represented. > > >> def f(x): > >>   #body > > >> That it, if I call f(10),

Re: Comparison of parsers in python?

2009-09-20 Thread Simon Forman
On Sep 19, 9:34 pm, Peng Yu wrote: > On Sep 19, 6:05 pm, Robert Kern wrote: > > > Peng Yu wrote: > > > Hi, > > > > I did a google search and found various parser in python that can be > > > used to parse different files in various situation. I don't see a page > > > that summarizes and compares a

Re: What are the naming convention for private member variable, and private and public member function?

2009-09-20 Thread Simon Forman
On Sep 19, 11:33 pm, Peng Yu wrote: > Hi, > > It says inhttp://www.python.org/dev/peps/pep-0008/ > > "    Method Names and Instance Variables > >       Use the function naming rules: lowercase with words separated by >       underscores as necessary to improve readability. > >       Use one leadin

Re: How to change string or number passed as argument?

2009-09-20 Thread Simon Forman
On Sep 19, 9:59 pm, Peng Yu wrote: > Hi, > > I know that strings or numbers are immutable when they passed as > arguments to functions. But there are cases that I may want to change > them in a function and propagate the effects outside the function. I > could wrap them in a class, which I feel a

Re: How to improve this code?

2009-09-18 Thread Simon Forman
On Sep 14, 9:08 pm, Oltmans wrote: > Hello, > > Is there someway I can improve the following code(pythonically)? > (Copying from IDLE) > match=[1,2,3,4,5] > > def elementsPresent(aList): >         result=False >         if not aList: >                 return False >         for e in aList: >      

Re: detmining name during an assignment

2009-09-18 Thread Simon Forman
On Sep 18, 1:00 pm, Jamie Riotto wrote: > I have an app that uses Python scripting. When a user creates a new object: > > objName = newObject() > > I'd like the newObject be able to use objName as its internal name. > So, if a user says: > > cube1 = Cube() > >  A "cube1" object should apear in the

Re: Why use "locals()"

2009-09-18 Thread Simon Forman
On Mon, Sep 14, 2009 at 1:12 AM, Sean DiZazzo wrote: > > Thanks for your explanation Steven.  I see how it can be valuable, but > it seems to always break the second rule of Zen.  I don't really want > to get into the code of debuggers, but I guess I can see how they > might have no other way to k

Re: Urllib2 not working

2009-08-22 Thread Simon Forman
On Sat, Aug 22, 2009 at 2:12 PM, Carlos Fabian Ramirez wrote: > Hello, > When I try to open a URL using urllib2.urlopen it returns Name or service > not known. It is not a problem with my Internet I believe, since I have > Internet access on my computer, and I have verified it is not a syntax, or >

Re: TypeError while checking for permissions with os.access() on windows xp

2009-08-21 Thread Simon Forman
On Aug 21, 1:33 pm, ryniek90 wrote: > I've got some code that checks priviliges on two paths: > First - chosen by user > Second - hardcoded home directory represented by **os.getenv('HOME')** - > (os.getenv('HOME') works both on Linux and Windows) > > Here's the code: > " > def __check_set_perm(se

Re: Object Reference question

2009-08-21 Thread Simon Forman
On Aug 21, 12:12 pm, josef wrote: > > > I need the object reference name (a,b,c,d) from dk to use as input for > > > a file. > > > You'll have to track that yourself. > > I'm a bit shocked that there isn't a method for catching object > reference names. I think that something like a = MyClass0(nam

Re: Object Reference question

2009-08-21 Thread Simon Forman
On Aug 21, 2:07 am, josef wrote: > To begin, I'm new with python. I've read a few discussions about > object references and I think I understand them. > > To be clear, Python uses a "Pass By Object Reference" model. > x = 1 > x becomes the object reference, while an object is created with the > ty

Re: incrementing string/hex value from file and write back

2009-08-20 Thread Simon Forman
On Aug 20, 5:18 pm, "Rami Chowdhury" wrote: > > val = val.encode('hex') > > That's the crucial line -- it's returning a new integer, which you are   > re-binding to val. If you then did: No, it returns another string, which still isn't the decimal representation of the hex string. hex C => decim

Re: incrementing string/hex value from file and write back

2009-08-20 Thread Simon Forman
On Aug 20, 5:08 pm, Matthias Güntert wrote: > Hello guys > > I would like to read a hex number from an ASCII file, increment it and > write it back. > How can this be performed? > > I have tried several approaches: > > my file serial.txt contains: 0C > > -- > f = op

Re: Annoying octal notation

2009-08-20 Thread Simon Forman
On Aug 20, 3:06 pm, David <71da...@libero.it> wrote: > Hi all, > > Is there some magic to make the 2.x CPython interpreter to ignore the > annoying octal notation? No. You would have to modify and recompile the interpreter. This is not exactly trivial, see "How to Change Python's Grammar" http://

Re: #elements of seq A in seq B

2009-08-19 Thread Simon Forman
On Aug 19, 11:34 pm, John Machin wrote: > On Aug 20, 12:12 pm, Simon Forman wrote: > > > On Aug 19, 8:17 pm, "Jan Kaliszewski" wrote: > > > If you mean: to count non overlaping occurences of string A in B > > > -- simply: > > > >    B.count(A

Re: #elements of seq A in seq B

2009-08-19 Thread Simon Forman
On Aug 19, 8:17 pm, "Jan Kaliszewski" wrote: > 20-08-2009 o 01:19:24 Neal Becker wrote: > > > What would be a time efficient way to count the number of occurrences of > > elements of sequence A in sequence B?  (in this particular case, these > > sequences are strings, if that matters). > > If you

Re: Need cleanup advice for multiline string

2009-08-19 Thread Simon Forman
On Aug 19, 12:05 am, Ben Finney wrote: > Simon Forman writes: > > On Tue, Aug 18, 2009 at 8:42 PM, Ben Finney > > wrote: > > > We're all unified by our humanity. Bringing any god into the picture > > > is surely counter to any goals of unity. > > >

Re: recording input from USB port and write to text file

2009-08-19 Thread Simon Forman
On Aug 18, 7:33 pm, Allan wrote: > Hi! I'm fairly new to Python.  I understand the basics basics but I'm > been trying to write a simple python code that will let me read input > data (such as mouse movement) from my USB port and write it in a text > file and I am so lost.  Can anyone help or dire

Re: Need cleanup advice for multiline string

2009-08-18 Thread Simon Forman
On Tue, Aug 18, 2009 at 8:42 PM, Ben Finney wrote: > Simon Forman writes: > >> Sexism, racism, homophobia, religious intolerance, etc., all stem from >> a fundamental forgetfulness of our Unity in God (as I would put it) > > It seems odd, for someone who cites religious

Re: Need cleanup advice for multiline string

2009-08-18 Thread Simon Forman
On Tue, Aug 18, 2009 at 8:03 PM, Steven D'Aprano wrote: > On Tue, 18 Aug 2009 17:13:02 -0400, Simon Forman wrote: > >> Sexism, racism, homophobia, religious intolerance, etc., all stem from a >> fundamental forgetfulness of our Unity in God (as I would put it) and > >

Re: Inheriting dictionary

2009-08-18 Thread Simon Forman
On Tue, Aug 18, 2009 at 6:08 PM, Simon Forman wrote: > On Aug 18, 3:44 pm, Pavel Panchekha wrote: >> I want a dictionary that will transparently "inherit" from a parent >> dictionary. So, for example: >> >> """ >> a = InheritDict({1: &quo

Re: Inheriting dictionary

2009-08-18 Thread Simon Forman
On Aug 18, 3:44 pm, Pavel Panchekha wrote: > I want a dictionary that will transparently "inherit" from a parent > dictionary. So, for example: > > """ > a = InheritDict({1: "one", 2: "two", 4: "four"}) > b = InheritDict({3: "three", 4: "foobar"}, inherit_from=a) > > a[1] # "one" > a[4] # "four" >

Re: Need cleanup advice for multiline string

2009-08-18 Thread Simon Forman
On Tue, Aug 18, 2009 at 1:05 PM, Jean-Michel Pichavant wrote: > Steve Holden wrote: Robert Dailey: >> >> [...] >> >>> >>> It's a figure of speech. And besides, why would I want programming >>> advice from a woman? lol. Thanks for the help. >>> >> >> Sorry, Robert, simply not acceptab

Re: define class over 2 files

2009-08-18 Thread Simon Forman
On Tue, Aug 18, 2009 at 1:57 AM, Steven D'Aprano wrote: > On Mon, 17 Aug 2009 21:45:57 -0700, naveen wrote: > >> Is it possible to split up a class definition over multiple files? > > Not exactly, but you can do variations of this: > > > In file A.py, create: > > class Parent: >    def method(self)

Re: comparing XML files to eachother

2009-08-18 Thread Simon Forman
On Mon, Aug 17, 2009 at 3:51 PM, David Brochu wrote: > I need to compare one xml document to another to see if the content matches. > Unfortunately, the formatting (spacing) and order of elements may change > between files from run to run. I have looked into xml dom minidom but can't > seem to find

Re: Splitting a string into substrings of equal size

2009-08-16 Thread Simon Forman
On Aug 14, 8:22 pm, candide wrote: > Suppose you need to split a string into substrings of a given size (except > possibly the last substring). I make the hypothesis the first slice is at the > end of the string. > A typical example is provided by formatting a decimal string with thousands > separ

Re: problem with interface of operator.itemgetter

2009-08-16 Thread Simon Forman
On Thu, Aug 13, 2009 at 11:16 PM, dou dou wrote: > I have a function to do some thing like LEFT JOIN in SQL, the function use > the itemgetter to get the "ON" and "SELECT" parameters of the two table(list > of list), the problem is that itemgetter may return a value or a tuple of > values, because

Re: Need cleanup advice for multiline string

2009-08-12 Thread Simon Forman
On Aug 12, 10:41 am, Robert Dailey wrote: > On Aug 12, 9:09 am, exar...@twistedmatrix.com wrote: > > > > > On 01:27 pm, jeanmic...@sequans.com wrote: > > > >Simon Brunning wrote: > > >>2009/8/11 Robert Dailey : > > >>>On Aug 11, 3:40 pm, Bearophile wrote: > > There are gals too here. > > >>>I

Re: dictionary help

2009-08-11 Thread Simon Forman
On Aug 11, 11:51 am, MRAB wrote: > Krishna Pacifici wrote: > > Thanks for the help. > > > Actually this is part of a much larger project, but I have unfortunately > > pigeon-holed myself into needing to do these things without a whole lot > > of flexibility. > > > To give a specific example I have

Re: Search and write to .txt file

2009-08-11 Thread Simon Forman
On Aug 11, 7:22 am, Helvin wrote: > Hi everyone, > > I am writing some python script that should find a line which contains > '1' in the data.txt file, then be able to move a certain number of > lines down, before replacing a line. At the moment, I am able to find > the line '1', but when I use f.

  1   2   3   4   5   >