Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.

2012-09-29 Thread Tim Delaney
On 30 September 2012 09:26, Chris Angelico wrote: > On Sun, Sep 30, 2012 at 6:51 AM, Tim Delaney > wrote: > > Personally I voted for the Fierce Snake[1][2] as the delimiter, but it > was > > voted down as "not Pythonic" enough. > > I'm sure they were

Re: Can somebody give me an advice about what to learn?

2012-09-30 Thread Tim Chase
On 09/30/12 07:58, tcgo wrote: > So, assuming you'll say me "learn python", why should I learn it > over Ruby? For me, most of Chris's answers apply to both Python and Ruby. Well, I can't speak regarding the Ruby community being as awesome, but it doesn't seem to scare off folks. *READABILITY* is

Re: Experimental Python-based shell

2012-10-02 Thread Tim Roberts
ility >and searching above pinpointing files in heirarchies. > >I invite you to try it. Without intending to detract from your work in any way, are you familiar with the IPython project? http://ipython.org/ You may find some interesting synergy with them. -- Tim Roberts, t...@prob

Re: mangled messages (was: Unpaking Tuple)

2012-10-09 Thread Tim Chase
On 10/09/12 02:22, Jussi Piitulainen wrote: >>> in 682592 20121008 232126 "Prasad, Ramit" wrote: > [snip mess] >>> How does one unpack this post? ;-) >> >> Since that's not the way it arrived here, i have to ask, how do you >> get these posts? > > I see a carriage return rendered as ^M at the end

Re: Private methods

2012-10-09 Thread Tim Chase
On 10/09/12 08:59, D.M. Procida wrote: >> On 09/10/2012 14:24, D.M. Procida wrote: >>> What exactly is the point of a private method? Why or when would I want >>> to use one? > > In Python, using an underscore is simply a convention to note that a > method is private - it doesn't actually hide it

Re: mangled messages

2012-10-09 Thread Tim Chase
On 10/09/12 07:05, Jussi Piitulainen wrote: > Tim Chase writes: >> However, it might be that there is no CR+LF on the last line, >> or that one line is missing the CR, so your viewer heuristic >> (vim does this) thinks it has Unix NL-only line-endings and >> shows the ^M

communicate with external process via pty

2012-10-09 Thread Tim Arnold
$\n') # feed more equations mathml.append(os.read(master,1024)) # get the next string Any suggestions for improvement? thanks, --Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating C++ code

2012-10-10 Thread Tim Roberts
e PHP code (it generates data access objects from a live database schema). -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Static analysis tools

2012-10-11 Thread Tim Leslie
Another one I've found useful for stylistic checking is pep8: https://github.com/jcrocholl/pep8 I find it to be complementary to the types of checks performed by pylint and use both of them in tandem on large projects I work on. Cheers, Tim > > We're considering doing static anal

Re: Aggressive language on python-list

2012-10-13 Thread Tim Delaney
That's what they want - it gives them an audience. No matter how much you want to *just this once* respond to one, resist the urge. And if you can't prevent yourself from replying to someone who has quoted one in order to tell them that the person is a known troll/bot, tell them privately, not on the list. Cheers, Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: Aggressive language on python-list

2012-10-13 Thread Tim Delaney
there is no reference to the troll/bot or any text from the troll/bot - fine. But any reference to the original will make it harder for those of us who use bayesian-based spam filtering. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: one obvious parser (was "Feedback on my python framework I'm building.")

2012-10-13 Thread Tim Chase
On 10/13/12 21:25, Steven D'Aprano wrote: > Not being Dutch, I don't know whether the obvious way to do command line > argument handling is the getopt module or argparse. But there certainly > isn't *only one way* to do command line argument handling. As an aside, I just watched a fascinating vi

Re: Understanding http proxies

2012-10-14 Thread Tim Roberts
not "www.bigsite.com", that receipient can tell exactly who is supposed to get the message. So, a web proxy receives requests intended for other sites, and forwards them on, possibly after restricting or modifying them. That's it. -- Tim Roberts, t...@probo.com Providenza & Boeke

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Tim Chase
On 10/18/12 04:33, wxjmfa...@gmail.com wrote: > I use a "double indentation". > if 'asdf' and 'asdf' and 'asdf' \ > ... 'asdf' and 'asdf' and \ > ... 'asdf' and 'asdf': > ... print('do if') > ... s = 'asdf' > ... ss = 'asdf' > ... > do if if looks_like_it

Re: Python on Windows

2012-10-19 Thread Tim Golden
On 19/10/2012 14:24, graham wrote: > Thanks to everyone who replied. > > Python was installed in the subdirectory C:\Python27 with the file > feedparser.py residing in C:\Python27\Lib\email. > > Setting the Windows environment variable (which did not previously > exist) to C:\Python27\Lib\email a

Re: Python on Windows

2012-10-19 Thread Tim Golden
On 19/10/2012 14:24, graham wrote: > Python was installed in the subdirectory C:\Python27 with the file > feedparser.py residing in C:\Python27\Lib\email. > > Setting the Windows environment variable (which did not previously > exist) to C:\Python27\Lib\email allowed me to import feedparser > succ

Re: Python on Windows

2012-10-19 Thread Tim Golden
[Could I suggest snipping some of the preceding replies unless you're referring directly to them? Just leave enough to make the context clear] [... attempts to find feedparser module for beginner's tutorial ...] On 19/10/2012 15:12, graham wrote: > Once again thanks to those that replied. > > Si

Re: Python on Windows

2012-10-19 Thread Tim Golden
On 19/10/2012 15:23, Mark Lawrence wrote: > On 19/10/2012 14:44, Tim Golden wrote: >> >> (In general, PyPI is the first place to look for Python packages). >> >> > > For the benefit of the OP and others this is worth reading on how to get > Python packag

Re: A desperate lunge for on-topic-ness

2012-10-19 Thread Tim Chase
On 10/19/12 17:14, Steven D'Aprano wrote: > Code never *needs* to be long, because it can always be shortened. I advocate one bit per line: 1 0 1 0 0 1 0 1 1 0 0 1 0 1 1 1 0 0 0 0 1 1 1 0 1 1 0 0 1 1 0 1 1 0 0 1 1 1 1 0 0 1 1 1 1 1 1 1 «grins, ducks, and flees» Shortenedly-yers, -tkc -- http

Re: pls help me with this prog

2012-10-20 Thread Tim Roberts
>= n: yield iter[:n] iter = iter[n:] Now you can do this: def main(data): for first3 in N_at_a_time(data, 3): print CalcCenter(first3) -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: printing (was: A desperate lunge for on-topic-ness)

2012-10-21 Thread Tim Chase
On 10/21/12 05:00, Steven D'Aprano wrote: > I seriously do print out source code. When I'm having trouble > seeing how the parts of a module fit together, reading print-outs > is a good way around the problem. I don't print my personal code--both in light of the fact that I know it much more intim

Re: Python does not take up available physical memory

2012-10-21 Thread Tim Delaney
ntioned. One I haven't seen here yet (I may have missed it) is dumping the data into a database of some form and using it's capabilities. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a way to programmatically turn on remote registry?

2012-10-22 Thread Tim Golden
On 22/10/2012 15:51, Kevin Holleran wrote: > Back at it this morning. The RPC was due to needing to run it under > another account (or so I think now...). However, the RemoteRegistry > service is not just STOPPED but DISABLED. > > I am trying to see if there is a call to actually set the state to

Re: Is there a way to programmatically turn on remote registry?

2012-10-22 Thread Tim Golden
On 22/10/2012 16:38, Kevin Holleran wrote: Thanks, I will look into that. WMI is enabled, but everything WMI query I wrote (& I am NOT a WMI expert or even close) gave me a bunch of NIC info, but not the info I am after in the registry (driver description, driver date, driver version for the

Re: Is there a way to programmatically turn on remote registry?

2012-10-23 Thread Tim Golden
On 22/10/2012 21:01, Kevin Holleran wrote: > Tim, > > I am looking here: > > SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{BF9F6FB0-C999-4D19-BED0-144F77E2A9D6} > > Enumerating the keys for a BusType == 5, then grabbing the values of > DriverDesc, DriverDate, &a

Re: Fast forward-backward (write-read)

2012-10-23 Thread Tim Chase
On 10/23/12 09:31, Virgil Stokes wrote: > I am working with some rather large data files (>100GB) that contain time > series > data. The data (t_k,y(t_k)), k = 0,1,...,N are stored in ASCII format. I > perform > various types of processing on these data (e.g. moving median, moving > average,

Re: Fast forward-backward (write-read)

2012-10-23 Thread Tim Chase
On 10/23/12 11:17, Paul Rubin wrote: > Virgil Stokes writes: >> Finally, to my question --- What is a fast way to write these >> variables to an external file and then read them in backwards? > > Seeking backwards in files works, but the performance hit is > significant. There is also a performa

Re: Fast forward-backward (write-read)

2012-10-23 Thread Tim Chase
On 10/23/12 12:17, Virgil Stokes wrote: > On 23-Oct-2012 18:09, Tim Chase wrote: >>> Finally, to my question --- What is a fast way to write these >>> variables to an external file and then read them in >>> backwards? >> Am I missing something, or would the fai

Re: Fast forward-backward (write-read)

2012-10-23 Thread Tim Chase
On 10/23/12 13:37, Virgil Stokes wrote: > Yes, I do wish to inverse the order, but the "forward in time" > file will be in binary. Your original post said: > The data (t_k,y(t_k)), k = 0,1,...,N are stored in ASCII format making it hard to know what sort of data is in this file. So I guess it

Re: Fast forward-backward (write-read)

2012-10-24 Thread Tim Golden
On 24/10/2012 08:07, Virgil Stokes wrote: > On 23-Oct-2012 22:03, Cousin Stanley wrote: >> Virgil Stokes wrote: >> >>> Not sure about "tac" --- could you provide more details on this >>> and/or a simple example of how it could be used for fast reversed >>> "reading" of a data file ? >>tac is av

Re: Is there a way to programmatically turn on remote registry?

2012-10-24 Thread Tim Golden
On 24/10/2012 12:40, Kevin Holleran wrote:> Here is the full traceback: > > [output] > Scan_NIC_Driver_Info_1.2.py -i > testing_MSK_Server.csv -o MSK_Test_output.csv -u unreachable.csv > Parsing input file... > > Connecting to IP... > > Traceback (most recent ca

Re: Is there a way to programmatically turn on remote registry?

2012-10-24 Thread Tim Golden
On 24/10/2012 13:36, Kevin Holleran wrote: > Here is the output as you requested. Again thanks for your time & help. > I hate monopolizing one person's time so much Heh. Everyone else is welcome to chip in :) Ok, try specifying the parameter names. (I remember someone having problems before

Re: Is there a way to programmatically turn on remote registry?

2012-10-24 Thread Tim Golden
On 24/10/2012 14:26, Kevin Holleran wrote: > On Wed, Oct 24, 2012 at 9:11 AM, Tim Golden Ok, try specifying the parameter names. (I remember someone having > problems before caused by mismatched param order): > > > > OK, tried that as well as specifying the parameter

Re: while expression feature proposal

2012-10-24 Thread Tim Chase
On 10/24/12 16:34, Ian Kelly wrote: > On Wed, Oct 24, 2012 at 2:40 PM, Dan Loewenherz wrote: >> So I'm sure a lot of you have run into the following pattern. I use it >> all the time and it always has felt a bit awkward due to the duplicate >> variable assignment. >> >> VAR = EXPR >> while VAR: >>

Re: while expression feature proposal

2012-10-24 Thread Tim Chase
On 10/24/12 17:26, Cameron Simpson wrote: > On 24Oct2012 16:54, Tim Chase wrote: > | On 10/24/12 16:34, Ian Kelly wrote: > | > The idiomatic way to do this is: > | > > | > while True: > | > VAR = EXPR > | > if not VAR: > | > break > |

Re: Listen for changes in variable (alsaaudio.Mixer(x, x).getvolume(x)

2012-10-24 Thread Tim Roberts
;re talking about real-time response makes me think you might be misunderstanding this. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about long-running web scripts

2012-10-25 Thread Tim Golden
On 25/10/2012 12:45, Gilles wrote: > I'd like to check something about running Python web applications. > > Generally speaking, the reason scripts run faster when called > through FastCGI or the mod_* modules, is because the interpreter is > already up and running. But when running PHP scripts, th

Re: Question about long-running web scripts

2012-10-25 Thread Tim Golden
On 25/10/2012 13:40, Gilles wrote: > On Thu, 25 Oct 2012 13:03:14 +0100, Tim Golden > wrote: >> (Your question is a little confused at the end. I'm choosing to >> understand: why can't we just run Python one-shot, like CGI? The likely >> alternative meaning is:

Re: Question about long-running web scripts

2012-10-26 Thread Tim Golden
On 26/10/2012 10:58, Gilles wrote: > On Thu, 25 Oct 2012 14:24:16 +0100, Tim Golden > wrote: >>> But actually, I didn't mean one-shot scripts, where the Python >>> interpreter + script must be loaded each time, but rather: If I leave >>> a Python runnin

Re: while expression feature proposal

2012-10-26 Thread Tim Chase
On 10/26/12 17:03, Cameron Simpson wrote: > On 26Oct2012 09:10, Paul Rubin wrote: > | while (client.spop("profile_ids") as profile_id) is not None: > > Now this pulls me from a -0 to a +0.5. > > Any doco would need to make it clear that no order of operation is > implied, so that this: > >

Re: while expression feature proposal

2012-10-27 Thread Tim Chase
On 10/26/12 19:18, Steven D'Aprano wrote: > def iterate_until_none_or_false(func, *args, **kwargs): > while True: > x = func(*args, **kwargs) > # Halt if x is None or False, but not other falsey values. > if x is None or x is False: > return > yield x

Re: pythonic way

2012-11-01 Thread Tim Chase
On 11/01/12 10:32, inshu chauhan wrote: > what is the most pythonic way to do this : > >if 0 < ix < 10 and 0 < iy < 10 ??? What's wrong with the syntax you provide? It's perfectly pythonic: ix = 42 yx = 3.14159 if 0 < ix < 10 and 0 < iy < 10: do_stuff(ix, iy) el

Re: Proper place for everything

2012-11-02 Thread Tim Golden
On 02/11/2012 11:20, Jason Benjamin wrote: > Anybody know of the appropriate place to troll and flame about various > Python related issues? I'm kind of mad about some Python stuff and I > need a place to vent where people may or may not listen, but at at least > respond. Thought this would be a

Re: Proper place for everything

2012-11-02 Thread Tim Golden
On 02/11/2012 13:49, Jason Benjamin wrote: > Yeah, alright. I've just found that if you mention anything about a > library that has well established competitors, the post will tend to get > ignored here. I'm not sure exactly what you're referring to. (Perhaps you can link to an existing post or d

Re: Proper place for everything

2012-11-02 Thread Tim Golden
On 02/11/2012 18:51, Jason Benjamin wrote: On another note, it appears that Google (the only archive I can find for this group) only has a little under 400 messages archived for this group http://mail.python.org/pipermail/python-list/ http://markmail.org/search/?q=python#query:python%20list

Re: How to generate account number?

2012-11-03 Thread Tim Chase
On 11/03/12 08:22, Roy Smith wrote: > Even better might be base-32 encoding the value. Strings of > digits have an information density of about 3.2 bits/char. > Base-32 is just about as readable, but gives you 5 bits/char, so > you end up with a few less characters (which you still want to > chunk

Re: Executing .exe on a remote Windows machine

2012-11-08 Thread Tim Golden
On 08/11/2012 14:25, Kevin Holleran wrote: > Good morning, > > I wrote a python script to connect out to a bunch of my remote machines > that are running some software. It modifies a bunch of the config files > for me. After making the changes, I need to restart the software. The > way to do th

Re: Executing .exe on a remote Windows machine

2012-11-08 Thread Tim Golden
On 08/11/2012 15:37, Kevin Holleran wrote: > [code] > try: > print("Attempting to restart Splunk...") > subprocess.call(["psexec", "" + host, "'c:\\Program > Files\\Splunk\\bin\\splunk.exe'", "restart"]) > [/code] > > & am getting: > > [output] > Attempting to restart

Re: awk like usage in python

2012-11-09 Thread Tim Roberts
OS_: extract the 15 lines starting with T(est) from the file out-Dy-eos2 to a temporary file extract the 2nd field from the line with T(est) in it extract the 6th field from the first line with "s1,torque" extract the 7th field from the first line with "s1,torque&quo

Re: List comprehension for testing **params

2012-11-11 Thread Tim Chase
> assert[key for key in required if key in params.keys()] ... > Could you explain why it doesn't work and do you have any idea of how it > could work ? Well, here, if any of the items are found, you get a list that is non-False'ish, so the assert passes. It sounds like you want all() (available

Re: List comprehension for testing **params

2012-11-11 Thread Tim Chase
On 11/11/12 17:18, Steven D'Aprano wrote: > but that leaves you with the next two problems: > > 2) Fixing the assert still leaves you with the wrong exception. You > wouldn't raise a ZeroDivisionError, or a UnicodeDecodeError, or an IOError > would you? No of course not. So why are you suggestin

Re: Subprocess puzzle and two questions

2012-11-13 Thread Tim Roberts
ystem), and that command has a different output format. The csh "time" command is different yet again. >1) how can I recover that third digit from the subprocess? Do you actually believe that the third decimal place has any meaning at all? It doesn't. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Detect file is locked - windows

2012-11-14 Thread Tim Golden
On 14/11/2012 08:55, Hans Mulder wrote: > On 14/11/12 02:14:59, Mark Lawrence wrote: >> On 14/11/2012 00:33, Ali Akhavan wrote: >>> I am trying to open a file in 'w' mode open('file', 'wb'). open() will >>> throw with IOError with errno 13 if the file is locked by another >>> application or if user

Re: Detect file is locked - windows

2012-11-14 Thread Tim Golden
On 14/11/2012 00:33, Ali Akhavan wrote: > I am trying to open a file in 'w' mode open('file', 'wb'). open() > will throw with IOError with errno 13 if the file is locked by > another application or if user does not have permission to open/write > to the file. What version of Python are you using?

Re: Detect file is locked - windows

2012-11-14 Thread Tim Golden
On 14/11/2012 00:33, Ali Akhavan wrote: > I am trying to open a file in 'w' mode open('file', 'wb'). open() > will throw with IOError with errno 13 if the file is locked by > another application or if user does not have permission to open/write > to the file. > > How can I distinguish these two ca

Re: Detect file is locked - windows

2012-11-14 Thread Tim Golden
On 14/11/2012 11:51, Hans Mulder wrote: > It would be nice if he could give specific error messages, e.g. > > "Can't write %s because it is locked by %s." > > vs. > > "Can't write %s because you don't have write access." > > I can't speak for Ali, but I'm always annoyed by error message

Re: editing conf file

2012-11-16 Thread Tim Chase
On 11/16/12 07:04, Thomas Bach wrote: > On Fri, Nov 16, 2012 at 01:48:49PM +0100, chip9munk wrote: >> configparser has four functions: get, getboolean, getfloat and getint. >> >> how do I get list from cfg file?! > > AFAIK you have to parse the list yourself. Something like > > my_list = [ s.stri

Re: Problem with subprocess.call and windows schtasks

2012-11-18 Thread Tim Golden
On 18/11/2012 13:48, Tom Borkin wrote: import subprocess #subprocess.call(['SchTasks /Create /SC ONCE /TN "My Tasks" /TR "C:/Program Files/Apache Group/Apache2/htdocs/ccc/run_alert.py" /ST 07:50'], shell=True) subprocess.call(['SchTasks /Create /SC ONCE /TN "test" /TR "run_alert.py" /ST 07:50'],

Re: Splitting a line while keeping quoted items together

2012-11-19 Thread Tim Chase
>> Use the "shlex" module in the std lib? > > Well color me ignorant. > > Works cleanly. I shouldn't have reinvented the wheel. I've experienced this enough: the csv module, option parsing, config-file parsing, logging, timeit, and pwd all come to mind as code I've written before realizing the s

Re: changing process name

2012-11-19 Thread Tim Roberts
andrea crotti wrote: >I have very long processes to spawn which I want to lauch as separate >processes (and communicate with ZeroMQ), but now the problem is that the >forked process appears in "ps" with the same name as the launcher >process. http://code.google.com/p/py

Re: 10 sec poll - please reply!

2012-11-20 Thread Tim Chase
On 11/20/12 06:18, Michael Herrmann wrote: > am having difficulty picking a name for the function that > simulates key strokes. I currently have it as 'type' but that > clashes with the built-in function. Just to add one more to the pot, Vim uses "feedkeys()" for a similar purpose. -tkc -- ht

Re: 10 sec poll - please reply!

2012-11-20 Thread Tim Chase
On 11/20/12 19:17, Steven D'Aprano wrote: > On Tue, 20 Nov 2012 18:00:59 -0600, Tim Chase wrote: >> Just to add one more to the pot, Vim uses "feedkeys()" for a similar >> purpose. > > What does it feed to the keys? In Vim's case, the signature would be

Re: 10 sec poll - please reply!

2012-11-20 Thread Tim Chase
On 11/20/12 19:20, Steven D'Aprano wrote: > *Accidental* shadowing of names is a bad thing, because you get > unexpected bugs. *Deliberate* shadowing is not. We're all > consenting adults here, if somebody calls "from module import > type", and shadows the builtin type, that's their right to shoot

Re: windows question: default click action points to wrong python version

2012-11-21 Thread Tim Golden
On 21/11/2012 08:23, Gelonida N wrote: > Hi, > > I installed python 2.6 and python 2.7 on a windows 7 machine. > > At the moment Python 2.7 is the interpreter being used if I 'start' a > python script without explicit interpreter. > > I always thought, that 'repairing' Python 2.6 (reinstalling i

Re: Problem with subprocess.call and windows schtasks

2012-11-21 Thread Tim Golden
On 20/11/2012 23:41, Tom Borkin wrote: > Using shlex, I now have this: > #!\Python27\python > import os, subprocess > path = os.path.join("C:\\", "Program Files", "Apache Group", "Apache2", > "htdocs", "ccc", "run_alert.py") > #subprocess.call(['SchTasks', '/Create', '/SC', 'ONCE', '/TN', '"test"',

Re: windows question: default click action points to wrong python version

2012-11-21 Thread Tim Golden
On 21/11/2012 20:53, Tony the Tiger wrote: On Wed, 21 Nov 2012 09:23:00 +0100, Gelonida N wrote: What am I missing? The PATH environment variable? Nope. PATH doesn't affect either double-clicking or running a .py file on the command line (unless, obviously, you run it by typing "python my

Re: Convert tuples into string

2012-11-25 Thread Tim Chase
On 11/25/12 20:24, Smaran Harihar wrote: > I was able to solve it using the following loop, > > conn=psycopg2.connect(connstr) > cursor=conn.cursor() > cursor.execute("SELECT tablename FROM pg_tables where tablename like '%"+ > inp +"%'") > records = cursor.fetchall() > str="" > for rec in record

Re: os.popen and the subprocess module

2012-11-28 Thread Tim Roberts
place almost every use case for os.system and os.popen. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: send email with bcc

2012-11-30 Thread Tim Golden
On 30/11/2012 20:25, Ed wrote: to = 'e...@domain.gov' bcc = 'e...@domain.net' [... snippage ...] smtp.sendmail(sender, [to] + bcc, msg.as_string()) Well, you crucially don't show us the rest of the traceback. But I imagine you'd have got something like this: ActivePython 2.7.2.5 (Activ

Re: assign only first few items of a tuple/list

2012-12-04 Thread Tim Chase
On 12/04/12 15:36, Chris Angelico wrote: > On Wed, Dec 5, 2012 at 8:25 AM, Daniel Fetchinson > wrote: >> Hi folks, I swear I used to know this but can't find it anywhere. >> Say I have a list x = [ 1,2,3,4,5 ] and only care about the first two items. >> I'd like to assign the first two items to tw

Re: why does dead code costs time?

2012-12-05 Thread Tim Roberts
areful about spelling (and pronouncing) the whole word "peephole". The word as you have spelled it here (twice) is a vulgarity. Now, I'm all in favor of the occasional vulgarity, but if this is a misunderstanding, you could find yourself as the butt of some awkward jokes at s

Re: Some help in refining this regex for CSV files

2012-12-06 Thread Tim Chase
On 12/06/12 01:21, Oltmans wrote: > Hi guys, > > I've to deal with CSVs that look like following > > CSV (with one header and 3 legit rows where each legit row has 3 columns) > > Some info > Date: 12/6/2012 > Author: Some guy > Total records: 100 > > header1, header2, header3 > one, two, th

Re: String manipulation in python..NEED HELP!!!!

2012-12-11 Thread Tim Delaney
the anti-pattern of string concatenation, not to encourage people to use it. As a real-world case, a bug was recently found in Mercurial where an operation on Windows was taking orders of magnitudes longer than on Linux due to use of string concatenation rather than the join idiom (from ~12 seconds spent on string concatenation to effectively zero). Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

PyParsing contextual suggestions?

2012-12-11 Thread Tim Chase
I've just started tinkering around with PyParsing and have unable to come up with an answer to the following without deep diving into the code. Is there a way to do a partial parsing and then get the list of possible things that could appear at the terminus of the parsing? My hope is to implement

Re: Iterating over files of a huge directory

2012-12-17 Thread Tim Golden
On 17/12/2012 15:41, Chris Angelico wrote: > On Tue, Dec 18, 2012 at 2:28 AM, Gilles Lenfant > wrote: >> Hi, >> >> I have googled but did not find an efficient solution to my >> problem. My customer provides a directory with a hge list of >> files (flat, potentially 10+) and I cannot rea

Re: Delete dict and subdict items of some name

2012-12-17 Thread Tim Chase
On 12/17/12 11:43, Mitya Sirenef wrote: > On 12/17/2012 12:27 PM, Gnarlodious wrote: >> Hello. What I want to do is delete every dictionary key/value >> of the name 'Favicon' regardless of depth in subdicts, of which >> there are many. What is the best way to do it? > > Something like this should

Re: calculation on lists

2012-12-19 Thread Tim Chase
On 12/19/12 09:24, loïc Lauréote wrote: >> is there a tool to calculate on list ? >> >> something like : >> >>> a= [1,1,1,1] >>> b = [5,9,8,4] >>> c = a+b*a >>> print c >>> [6,10,9,5] >> >> Thx >> >> == >> >> Hi, >> for such simpler cases, you may try list comprehensions and probably >> the zi

Re: Python USB control on Windows 7?

2012-12-22 Thread Tim Roberts
asily, no. It's not really a USB device -- I'm betting it doesn't even enumerate. It's just sucking power from the USB wires. There's nothing to control. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Integer as raw hex string?

2012-12-24 Thread Tim Chase
On 12/24/12 09:36, Roy Smith wrote: > I have an integer that I want to encode as a hex string, but I don't > want "0x" at the beginning, nor do I want "L" at the end if it happened > to be a long. The result needs to be something I can pass to int(h, 16) > to get back my original integer. > >

Re: Finding the name of a function while defining it

2012-12-26 Thread Tim Roberts
more obscure: two = lamba : "one" one = two Which one of these is the "name" of the function? -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: I am facing an issue while decoding json string using json.loads

2012-12-26 Thread Tim Roberts
ng also contains one instance of \\] . Who is doing the JSON encoding? It appears to be doing it incorrectly. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the name of a function while defining it

2012-12-27 Thread Tim Chase
On 12/27/12 04:58, Steven D'Aprano wrote: > On Wed, 26 Dec 2012 23:46:31 -0800, Abhas Bhattacharya wrote: > two = lamba : "one" one = two >>> Which one of these is the "name" of the function? > [...] >> If i call one() and two() respectively, i would like to see "one" and >> "two".

Re: New to python, do I need an IDE or is vim still good enough?

2012-12-27 Thread Tim Chase
On 12/27/12 14:01, mogul wrote: > Do I really need a real IDE, as the windows guys around me say I > do, or will vim, git, make and other standalone tools make it the > next 20 years too for me? Coding Python (and before that C, Pascal, and even some VB in there) using vi/vim has worked for about

Re: Finding the name of a function while defining it

2012-12-28 Thread Tim Roberts
x27;t know just one name, and when a function object is invoked, it has NO IDEA what name was used to invoke it. The information is simply not available. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: pickle module doens't work

2012-12-28 Thread Tim Roberts
train it every time >anew? Is there no way to save its trained values? When you say "train on data", what do you mean? If your training creates computed data in other members, those members and their values should also be saved in the pickle. -- Tim Roberts, t...@probo.com Provide

Re: dict comprehension question.

2012-12-29 Thread Tim Chase
On 12/29/12 15:40, Mitya Sirenef wrote: >>> w = [1,2,3,1,2,4,4,5,6,1] >>> s = set(w) >>> s set([1, 2, 3, 4, 5, 6]) >>> {x:w.count(x) for x in s} {1: 3, 2: 2, 3: 1, 4: 2, 5: 1, 6: 1} Indeed, this is much better -- I didn't think of it.. Except that you're st

Re: New to python, do I need an IDE or is vim still good enough?

2012-12-29 Thread Tim Johnson
s wonderful to have all of the choices. """ They'll take away my vim when they pry it from my cold, dead fingers. """ -- Tim tim at tee jay forty nine dot com or akwebsoft dot com http://www.akwebsoft.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Considering taking a hammer to the computer...

2012-12-31 Thread Tim Chase
On 12/31/12 19:30, worldsbiggestsabres...@gmail.com wrote: Here is what I've learned: [snip] 4) It's New Year's Eve and I'm trying to learn Python...? Can't think of a much better way to spend New Year's Eve, unless you're learning Python while also watching fireworks. :-) -tkc -- http

Re: New to python, do I need an IDE or is vim still good enough?

2013-01-01 Thread Tim Chase
On 01/01/13 04:12, Cameron Simpson wrote: I must admit I find Apple's "help" search box neat this way - you can type a keyword is it will actually find the menu item for you. Not that I use this for vi, of course... If you've not used it, Vim's ":helpgrep" command provides full Vim regexp powe

Re: pickle module doens't work

2013-01-01 Thread Tim Roberts
ed the "train" method, there IS no MaxEntClassifier object. Once you have called "train", you should be able to pickle the new MaxEntClassifier and fetch it back with its state intact. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: the class problem

2013-01-01 Thread Tim Roberts
to derive from the "object" base class. The class is still simply called "haha", and to create an instance of the class "haha", you write "haha()". -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: got stuck in equation

2013-01-01 Thread Tim Roberts
y, it isn't practical to solve this for SN. That probably means you're going to need a iterative solution. That is, you start with a guess, see how far off you are, and refine the guess until you narrow in on a solution. That means you'll have to figure out whether raising SN gets you c

Re: Creating interactive command-line Python app?

2013-01-03 Thread Tim Chase
(original post from planetthoughtful didn't seem to arrive here, so replying to Bob's reply) Newbie to Python, and I'm wondering if it's possible to create a Python console app that prompts for further input on the command line when run (in Windows XP, if that's important)? While Bob's sugges

Re: Creating interactive command-line Python app?

2013-01-03 Thread Tim Chase
On 01/03/13 08:41, Dave Angel wrote: The two replies in 2005 mentioned both raw_input and the cmd module (in case that's what he was implying). They were posted within 90 minutes of the original. Ah. 2005 would explain why my newsreader has purged them as ancient history :) Thanks for the c

Re: Yet another attempt at a safe eval() call

2013-01-03 Thread Tim Chase
On 01/03/13 17:25, Grant Edwards wrote: def lessDangerousEval(expr): global symbolTable if 'import' in expr: raise ParseError("operand expressions are not allowed to contain the string 'import'") globals = {'__builtins__': None} locals = symbolTable return eval

Re: New to python, do I need an IDE or is vim still good enough?

2013-01-04 Thread Tim Chase
On 01/04/13 01:34, Anssi Saari wrote: Ben Finney writes: And any decent Unix-alike (most OSen apart from Windows) comes with its own IDE: the shell, a good text editor (Vim or Emacs being the primary candidates), and a terminal multiplexor (such as ‘tmux’ or GNU Screen). Just curious since I

Re: Need a specific sort of string modification. Can someone help?

2013-01-05 Thread Tim Chase
On 01/05/13 02:35, Sia wrote: I have strings such as: tA.-2AG.-2AG,-2ag or .+3ACG.+5CAACG.+3ACG.+3ACG The plus and minus signs are always followed by a number (say, i). I want python to find each single plus or minus, remove the sign, the number after it and remove i characters after that. So

Re: Need a specific sort of string modification. Can someone help?

2013-01-05 Thread Tim Chase
On 01/05/13 11:24, Tim Chase wrote: I don't know how this version times out: import re r = re.compile(r"[-+](\d+)([^-+]*)") def modify(m): result = m.group(2)[int(m.group(1)):] return result Doh, I intended to change this after testing, making it

Re: Good Python IDE

2013-01-06 Thread Tim Johnson
nd and 3rd features you refer to were available, but the first was. It is easy enough to try. Now I use vim for all of my work. I pretty-much hand-rolled my own IDE, which is typical of vimmers. -- Tim tim at tee jay forty nine dot com or akwebsoft dot com http://www.akwebsoft.com -- http://ma

Re: Good Python IDE

2013-01-06 Thread Tim Johnson
* Tetsuya [130106 14:43]: > On 01/06/2013 11:13 PM, Tim Johnson wrote: > > Now I use vim for all of my work. I pretty-much hand-rolled my own > > IDE, which is typical of vimmers. > > I did like you, too. > I use vim for everything: coding in python, django, js, ht

<    1   2   3   4   5   6   7   8   9   10   >