Re: Making safe file names

2013-05-09 Thread Tim Chase
On 2013-05-10 12:04, Gregory Ewing wrote: > Roy Smith wrote: > > http://en.wikipedia.org/wiki/The_band > > Nope... googling for "the band" brings that up as the > very first result. > > The Google knows all. You cannot escape The Google... That does it. I'm naming my band "Google". :-) -tkc

Re: spilt question

2013-05-16 Thread Tim Chase
On 2013-05-16 08:00, loial wrote: > I want to split a string so that I always return everything BEFORE > the LAST underscore > > HELLO_.lst # should return HELLO > HELLO_GOODBYE_.ls # should return HELLO_GOODBYE > > I have tried with rsplit but cannot get it to work. .r

Re: Number of cells, using CSV module

2013-05-16 Thread Tim Chase
On 2013-05-16 14:07, Skip Montanaro wrote: > > len(reader) gives me an error. > > Apologies. len(list(reader)) should work. Of course, you'll wind > up loading the entire CSV file into memory. You might want to just > count row-by-row: > > n = 0 > for row in reader: > n += 1 which can nic

Re: Number of cells, using CSV module

2013-05-16 Thread Tim Chase
On 2013-05-16 14:08, Skip Montanaro wrote: > > So rather than > >>a > >>b > >>c > >>d > >>e > >>f > > I would get [a, b, c, d, e, f] > > all_items = [] > for row in reader: > all_items.append(row[0]) And following up here, this could be tidily rewritten as all_items = [row[0] for row in re

Re: A computer programmer, web developer and network admin resume

2013-05-21 Thread Tim Chase
On 2013-05-22 01:15, i...@databaseprograms.biz wrote: > A computer programmer, web developer and network administrator ...walk into a bar... So what's the punchline? -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: A computer programmer, web developer and network admin resume

2013-05-22 Thread Tim Chase
On 2013-05-22 16:39, Chris Angelico wrote: > On Wed, May 22, 2013 at 12:32 PM, Tim Chase > wrote: > > On 2013-05-22 01:15, i...@databaseprograms.biz wrote: > >> A computer programmer, web developer and network administrator > > > > ...walk into a bar..

Re: Prepending string "@" to usernames

2013-05-24 Thread Tim Chase
On 2013-05-24 19:04, Thomas Murphy wrote: >> raw_address = "cookielover93 TheGermanHatesSaurkraut >> WhatsThatBoy932834" address_library = raw_address.split() >> print address_library >> >> final_address = [] >> for address in address_library: >> final_address.append("@" + str(address)) >> prin

Re: Create a file in /etc/ as a non-root user

2013-05-31 Thread Tim Chase
On 2013-06-01 01:20, Nobody wrote: > On Fri, 31 May 2013 02:12:58 -0700, BIBHU DAS wrote: > > Any Idea how to create a file in /etc as non-root user? > > This should not be possible. The language used is irrelevant. It's theoretically possible to pre-create the file (or a subdirectory) in /etc as

Re: How to increment date by week?

2013-06-04 Thread Tim Chase
On 2013-06-04 14:31, PieGuy wrote: >Starting on any day/date, I would like to create a one year > list, by week (start date could be any day of week). Having a > numerical week index in front of date, ie 1-52, would be a bonus. > ie, 1. 6/4/2013 2. 6/11/2013 3. 6/18/2013etc to # 52. i

Re: Do you consider Python a 4GL? Why (not)?

2013-06-04 Thread Tim Chase
On 2013-06-05 02:53, Carlos Nepomuceno wrote: > Do you consider Python a 4GL? Why (not)? Of course it's a 4GL ("4 Guido Language"). You think he wrote it for somebody else? Unless you have some magical list of criteria that makes your own definition of "4GL", in which case you should look at you

Re: Apache and suexec issue that wont let me run my python script

2013-06-05 Thread Tim Chase
On 2013-06-05 17:57, ru...@yahoo.com wrote: > On 06/05/2013 05:19 PM, Dennis Lee Bieber wrote: > stories over the years where people where convicted (or > at least charged with) violating the DMCA (or perhaps > equally draconian followup U.S. laws) even though they > clearly penetrated the system

Idiomatic Python for incrementing pairs

2013-06-07 Thread Tim Chase
Playing around, I've been trying to figure out the most pythonic way of incrementing multiple values based on the return of a function. Something like def calculate(params): a = b = 0 if some_calculation(params): a += 1 if other_calculation(params): b += 1 return (a,

Re: Idiomatic Python for incrementing pairs

2013-06-07 Thread Tim Chase
On 2013-06-07 23:46, Jason Swails wrote: > On Fri, Jun 7, 2013 at 10:32 PM, Tim Chase > > def calculate(params): > > a = b = 0 > > if some_calculation(params): > > a += 1 > > if other_calculation(params): > > b += 1 > >

Re: Idiomatic Python for incrementing pairs

2013-06-07 Thread Tim Chase
On 2013-06-08 07:04, Carlos Nepomuceno wrote: > alpha, beta = (1 if some_calculation(params) else 0, 1 if > other_calculation(params) else 0) This one sets them to absolute values, rather than the incrementing functionality in question: > > alpha += temp_a > > beta += temp_b The actual code

Re: Redirecting to a third party site with injected HTML

2013-06-09 Thread Tim Chase
On 2013-06-09 10:09, guytam...@gmail.com wrote: > I'm working on a new project and i want to receive a request from a > user and to redirect him to a third party site, but on the page > after i redirect my users i want to them to see injected html (on > the third party site.) As others have stated

Re: Re-using copyrighted code

2013-06-09 Thread Tim Chase
On 2013-06-09 19:30, Mark Janssen wrote: > Thanks for digging out the legal code. Upon reading, it is > stunningly clear that the legal system has not established a solid > framework or arching philosophy in which to contain and express the > desire (in law) to protect content creators of all kind

Re: Split a list into two parts based on a filter?

2013-06-10 Thread Tim Chase
On 2013-06-11 08:50, Chris Angelico wrote: > The iterator version strikes my fancy. Maybe this isn't of use to > you, but I'm going to try my hand at making one anyway. > > >>> def iterpartition(pred,it): > """Partition an iterable based on a predicate. > > Returns two iterables, for

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Tim Chase
On 2013-06-11 08:54, Chris Angelico wrote: > >> Another principle similar to 'Don't add extraneous code' is > >> 'Don't rebind builtins'. > > > > OK, we've all done it by accident (especially when starting out), > > but are there people that rebind builtins intentionally? > > There are times when

Re: "Don't rebind built-in names*" - it confuses readers

2013-06-10 Thread Tim Chase
On 2013-06-10 17:20, Mark Janssen wrote: > >> list = [] > >> Reading further, one sees that the function works with two > >> lists, a list of file names, unfortunately called 'list', > > > > That is very good advice in general: never choose a variable name > > that is a keyword. > > Btw,

Re: Version Control Software

2013-06-12 Thread Tim Chase
[much of my reply echos Chris but elaborate] On 2013-06-13 10:04, Chris Angelico wrote: > On Thu, Jun 13, 2013 at 9:27 AM, cutems93 > wrote: > > Currently I am considering four software: git, SVN, > > CVS, and Mercurial. > > Don't touch CVS unless you absolutely have to. SVN is also > distinctly

Re: Version Control Software

2013-06-12 Thread Tim Chase
On 2013-06-12 16:27, cutems93 wrote: > I am looking for an appropriate version control software for python > development, and need professionals' help to make a good decision. While I'm generally a git user (see my other email), I'll also put in a plug for Fossil which has

Re: Version Control Software

2013-06-13 Thread Tim Chase
On 2013-06-13 10:20, Serhiy Storchaka wrote: > 13.06.13 05:41, Tim Chase написав(ла): > > -hg: last I checked, can't do octopus merges (merges with more > > than two parents) > > > > +git: can do octopus merges > > Actually it is possible in Mercurial. Okay,

Re: My son wants me to teach him Python

2013-06-14 Thread Tim Chase
On 2013-06-14 17:21, Chris Angelico wrote: > On Fri, Jun 14, 2013 at 4:13 PM, Steven D'Aprano > wrote: > > Here's another Pepsi Challenge for you: > > > > There is a certain directory on your system containing 50 text > > files, and 50 non-text files. You know the location of the > > directory. Yo

Re: Don't feed the troll

2013-06-14 Thread Tim Chase
On 2013-06-14 13:56, D'Arcy J.M. Cain wrote: > > I prefer to simply mail the list. You should be able to mute > > entire threads, and he doesn't start more than a couple a day > > usually. > > But then I have to deal with each thread. I don't want to deal with > them at all. At least Thunderbird

Re: dynamic if statement

2013-06-18 Thread Tim Chase
On 2013-06-18 07:10, upperdec...@gmail.com wrote: > I have a set of queries that are run against various > databases/tables. The result is all the same in that I always get > back the same field names. > > I query fld1, fld2, fld3, qty, qty2 from table1 > then I loop thru the results > if fld1

Re: dynamic if statement

2013-06-18 Thread Tim Chase
On 2013-06-18 16:27, Mark Lawrence wrote: > On 18/06/2013 15:56, Tim Chase wrote: > > name_index_map = dict( > >(info[0], i) > >for info, i in enumerate(cursor.description) > > Looks like this should be :- > for i, info in enumerate(cursor.des

Re: Default Value

2013-06-20 Thread Tim Chase
On 2013-06-21 01:08, Steven D'Aprano wrote: > Here's my syntax plucked out of thin air: > > def func(arg, x=expression, !y=expression): > ... > > where y=expression is late-bound, and the above is compiled to: > > def func(arg, x=expression, y=None): > if y is None: > y = express

Re: Default Value

2013-06-20 Thread Tim Chase
On 2013-06-20 21:40, Roy Smith wrote: > In article , > Tim Chase wrote: > > > On 2013-06-21 01:08, Steven D'Aprano wrote: > > > Here's my syntax plucked out of thin air: > > > > > > def func(arg, x=expression, !y=expression): > > >

Re: Python development tools

2013-06-23 Thread Tim Chase
On 2013-06-23 20:22, Roy Smith wrote: > In article , > ru...@yahoo.com wrote: >> Other things like finding all uses of various objects/functions >> etc would also be useful now and then but I suppose that is a >> common IDE capability? > > $ find . -name '*.py' | xargs grep my_function_name > >

Re: Is this PEP-able? fwhile

2013-06-24 Thread Tim Chase
On 2013-06-25 07:38, Chris Angelico wrote: > Python has no issues with breaking out of loops, and even has > syntax specifically to complement it (the 'else:' clause). Use > break/continue when appropriate. from minor_gripes import breaking_out_of_nested_loops_to_top_level -tkc -- http://mail.

Re: Is this PEP-able? fwhile

2013-06-24 Thread Tim Chase
On 2013-06-24 23:39, Fábio Santos wrote: > On 24 Jun 2013 23:35, "Tim Chase" wrote: > > On 2013-06-25 07:38, Chris Angelico wrote: > > > Python has no issues with breaking out of loops, and even has > > > syntax specifically to complement it (the 'els

Re: SQL code generation from table-free boolean queries?

2013-06-26 Thread Tim Chase
On 2013-06-26 16:17, Foo Stack wrote: > Given string input such as: > foo=5 AND a=6 AND date=now OR date='2013/6' AND bar='hello' > > I am going to implement: > > - boolean understanding (which operator takes precendence) > - spliting off of attributes into my function which computes their >

Re: Why is the argparse module so inflexible?

2013-06-27 Thread Tim Chase
On 2013-06-28 09:02, Cameron Simpson wrote: > On 27Jun2013 11:50, Ethan Furman wrote: > | If the OP is writing an interactive shell, shouldn't `cmd` be used > | instead of `argparse`? argparse is, after all, intended for > | argument parsing of command line scripts, not for interactive > work. >

Re: Closures in leu of pointers?

2013-06-29 Thread Tim Chase
On 2013-06-29 19:19, Steven D'Aprano wrote: > Nobody ever asks why Python doesn't let you sort an int, or take > the square of a list... just to be ornery, you can sort an int: >>> i = 314159265 >>> ''.join(sorted(str(i))) '112345569' And I suppose, depending on how you define it, you can square

Re: Persistence of CGI (was: OSError [Errno 26] ?!?!)

2013-07-02 Thread Tim Chase
On 2013-07-03 00:19, Steven D'Aprano wrote: > CGI didn't stop working just because more powerful, or better, > alternatives now exist. And for most exceptionally cheap hosting services, your choices are usually limited to PHP, static HTML (possibly server-side includes if you're lucky), or CGI.

Re: DOS or not? [was Re: How to tell Script to use pythonw.exe ?]

2013-07-03 Thread Tim Chase
On 2013-07-03 09:51, Tim Golden wrote: > We can certainly agree on this. I can't count the number of emails > I've deleted as too hot-headed in response to dismissive comments > about Windows as a platform. Some of them, at least, appear to be > from people who last actually used Windows back in th

Re: Important features for editors

2013-07-04 Thread Tim Chase
On 2013-07-04 05:02, Dave Angel wrote: [snip an excellent list of things to look for in an editor] Also, - the ability to perform changes in bulk, especially across files. Often, this is done with the ability to record/playback macros, though some editors have multiple insertion/edit cursors

Re: Important features for editors

2013-07-04 Thread Tim Chase
On 2013-07-04 15:24, MRAB wrote: > On 04/07/2013 14:22, Tim Chase wrote: > > Other nice-to-haves include > > > > - Unicode support (including various encodings) > > It's 2013, yet Unicode support is merely a "nice-to-have"? Yeah, while I use Vim and it&

Re: Geo Location extracted from visitors ip address

2013-07-05 Thread Tim Chase
On 2013-07-05 22:08, Νίκος Gr33k wrote: > Is there a way to extract out of some environmental variable the > Geo location of the user being the city the user visits out website > from? > > Perhaps by utilizing his originated ip address? Yep. You can get an 11MB database (17MB uncompressed) http

Re: Geo Location extracted from visitors ip address

2013-07-05 Thread Tim Chase
On 2013-07-05 22:59, Support by Νίκος wrote: > Στις 5/7/2013 10:58 μμ, ο/η Tim Chase έγραψε: > > On 2013-07-05 22:08, Νίκος Gr33k wrote: > >> Is there a way to extract out of some environmental variable the > >> Geo location of the user being the city the user v

Re: Geo Location extracted from visitors ip address

2013-07-06 Thread Tim Chase
On 2013-07-06 11:41, Νίκος Gr33k wrote: > you know when i go to maps.google.com its always find my exact city > of location and not just say Europe/Athens. > > and twitter and facebook too both of them pinpoint my _exact_ > location. > > How are they able to do it? We need the same way. A couple

Re: Geo Location extracted from visitors ip address

2013-07-06 Thread Tim Chase
On 2013-07-06 23:14, Νίκος Gr33k wrote: Can you be more specific please about using the aforementioned > HTML5 location API ? https://www.google.com/search?q=html5+location+api It's client-side JavaScript. > Never heard of it. Can it be utilizized via a python cgi script? Because it's client-s

Re: Geo Location extracted from visitors ip address

2013-07-06 Thread Tim Chase
On 2013-07-06 23:12, Νίκος Gr33k wrote: > I though that the ownership of the script file controlled the > privileges it runs under. Only if the script is SUID. In some environments, scripts can't be run SUID, only binaries. > Who controlls the script's privileges then? > The process that cal

Re: GeoIP2 for retrieving city and region ?

2013-07-14 Thread Tim Chase
On 2013-07-13 16:57, Michael Torrie wrote: > On 07/13/2013 12:23 PM, Νικόλας wrote: > > Do you know a way of implementing anyone of these methods to a > > script? > > Yes. Modern browsers all support a location API in the browser for > javascript. And the good browsers give the user the option

Re: [Savoynet] G&S Opera Co: Pirates of Penzance

2013-07-28 Thread Tim Chase
On 2013-07-28 16:49, Ethan Furman wrote: > On 07/28/2013 10:57 AM, Chris Angelico wrote: > . > . > . > > Okay, how did you get confused that this was a Python List > question? ;) Must have been this ancient thread http://mail.python.org/pipermail/python-list/2006-September/376063.ht

Re: import syntax

2013-07-29 Thread Tim Chase
On 2013-07-29 15:48, Devyn Collier Johnson wrote: > The PEP8 recommends importing like this: > > import os > import re > > not like this: > > import os, re > > Why is that? Is there a performance advantage to one of the styles? While I don't believe there's much of a performance difference (if

Re: import syntax

2013-07-29 Thread Tim Chase
On 2013-07-29 16:09, Dave Angel wrote: > On 07/29/2013 03:48 PM, Devyn Collier Johnson wrote: > > The PEP8 recommends importing like this: > > > > import os > > import re > > > > not like this: > > > > import os, re > > I got a bit further, and if I'm only using a couple of functions > from the imp

Re: PEP8 79 char max

2013-07-31 Thread Tim Chase
On 2013-07-31 07:16, Joshua Landau wrote: > On 30 July 2013 18:52, Grant Edwards wrote: >> I also find intializers for tables of data to be much more easily >> read and maintained if the columns can be aligned. > > Why do you have tables in your Python code? I've had occasion to write things like

Re: Best data structure for DFS on large graphs

2012-07-03 Thread Tim Chase
On 07/03/12 08:39, Miheer Dewaskar wrote: > On Tue, Jul 3, 2012 at 4:53 PM, Stefan Behnel wrote: >> >> Miheer Dewaskar, 03.07.2012 13:11: >>> I am not sure,but if there are large number of states Dictionaries wont >>> help much right? >> >> Dicts are fast for lookup, not for searching. >> > What d

Re: Python Interview Questions

2012-07-09 Thread Tim Chase
On 07/09/12 01:39, yeryomin.i...@gmail.com wrote: > On Tuesday, 30 October 2007 21:24:04 UTC+2, Tim Chase wrote: yes, yes I did, almost 5 years ago. :-) You didn't include any questions/comments on my email, so it's a bit hard to respond. >> While I haven't intervie

Re: Python Interview Questions

2012-07-09 Thread Tim Chase
On 07/09/12 08:25, Roy Smith wrote: >> On Tuesday, 30 October 2007 21:24:04 UTC+2, Tim Chase wrote: > >>> - more detailed questions about the std. libraries (such as >>>datetime/email/csv/zipfile/networking/optparse/unittest) > > You need to be careful whe

Re: Python Interview Questions

2012-07-09 Thread Tim Chase
On 07/09/12 17:53, Devin Jeanpierre wrote: >> One of my favourite questions when interviewing - and it was >> 100% reliable :-) - "what are your hobbies?" If the answer >> included programming then they were hired, if not, then they >> went to the "B" list. > > Woe is the poor college grad, who wa

Re: Python Interview Questions

2012-07-09 Thread Tim Chase
On 07/09/12 18:12, Cameron Simpson wrote: > On 09Jul2012 18:53, Devin Jeanpierre wrote: > | On Mon, Jul 9, 2012 at 5:22 PM, Peter wrote: > | > One of my favourite questions when interviewing - and it was 100% > reliable :-) - "what are your hobbies?" > | > If the answer included programming then

Re: Python Interview Questions

2012-07-09 Thread Tim Chase
On 07/09/12 19:01, dnca...@gmail.com wrote: > The set of questions I'm not sure I understand is the 'What > version did ... appear?' questions. This, to me, doesn't seem to > indicate any programming experience or expertise. A question > asking 'Do you understand different versions?' and 'How wou

Re: Python Interview Questions

2012-07-09 Thread Tim Chase
On 07/09/12 19:27, Roy Smith wrote: >> prefer folks that know which features to check availability for >> deployment. > > Heh. Tell me, when did strings get methods? :-) IIRC, ~2.0? I'm cognizant of the shift happening from the string module to string methods, but I wouldn't expect deep history

Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Tim Chase
On 07/17/12 12:24, Terry Reedy wrote: > On 7/17/2012 8:01 AM, Lipska the Kat wrote: >> In bash this is laughably trivial >> >> sort -nr $1 | head -${2:-10} > > Won't sort work alphabetically and leave the following as is? > > 1\talpha > 11\tbeta > 2\tgamma Only if Lipska had omitted the "-n" whi

Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Tim Chase
On 07/17/12 12:29, Ethan Furman wrote: > Terry Reedy wrote: >> On 7/17/2012 10:23 AM, Lipska the Kat wrote: >> >>> Well 'type-bondage' is a strange way of thinking about compile time type >>> checking and making code easier to read (and therefor debug >> >> 'type-bondage' is the requirement to rest

Odd csv column-name truncation with only one column

2012-07-19 Thread Tim Chase
tim@laptop:~/tmp$ python Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import csv >>> from cStringIO import StringIO >>> s = StringIO('Email\n...@example.com\n...@example.org\n') >>> s.seek(0) >>> d

Re: Odd csv column-name truncation with only one column

2012-07-19 Thread Tim Chase
On 07/19/12 06:21, Tim Chase wrote: > tim@laptop:~/tmp$ python > Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) > [GCC 4.4.5] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> import cs

Re: Odd csv column-name truncation with only one column

2012-07-19 Thread Tim Chase
On 07/19/12 08:52, Hans Mulder wrote: > Perhaps it should be documented that the Sniffer doesn't work > on single-column data. I think this would involve the least change in existing code, and go a long way towards removing my surprise. :-) > If you really need to read a one-column csv file, yo

Re: Encapsulation, inheritance and polymorphism

2012-07-19 Thread Tim Chase
> If you think that people can routinely detect infinite loops, then > perhaps you would care to tell me whether this is an infinite loop or not: > > i = 1 > while not is_perfect(i): > i += 2 > print "odd perfect number discovered" > > > where is_perfect() returns True if the integer argume

Re: Encapsulation, inheritance and polymorphism

2012-07-19 Thread Tim Chase
On 07/19/12 13:28, Chris Angelico wrote: > On Fri, Jul 20, 2012 at 4:20 AM, Tim Chase > wrote: >> Sure it terminates...If you don't run out of RAM to represent the >> number "i" in question, there's also this "heat death of the >> universe" l

Re: help

2012-07-19 Thread Tim Chase
On 07/19/12 17:31, Miriam Gomez Rios wrote: > Hello, sorry for bothering you, but I have a doubt, > > Is there a way to turn this string into a tuplelist??, I > need it for gurobi > > ('per1','persona1.1','pro1'),('per1','persona1.1','pro2'),('per1','persona1.1','pro3'),...,('per2','persona2.

Re: help

2012-07-19 Thread Tim Chase
On 07/19/12 18:26, Prasad, Ramit wrote: >> ('per1','persona1.1','pro1'),('per1','persona1.1','pro2'),('per1','persona1.1','pro3'),('per1','persona1.1','pro4'),('per1','persona1.1','pro5'),('per2','persona2.1','pro1'),('per2','persona2.1','pro2'),('per2','persona2.1','pro3'),('per2','persona2.1','pr

Re: help

2012-07-19 Thread Tim Chase
On 07/19/12 19:32, Miriam Gomez Rios wrote: s = "('per1','persona1.1','pro1'),('per1','persona1.1','pro2')" >> resulting_tuple_of_tuples = ast.literal_eval(s) > > Traceback (most recent call last): > File "C:\Users\Miriam\scripts\prueba_datos", line 124, in > print resulting_tuple.s

Re: append in IMAP4 from imaplib very slow

2012-07-25 Thread Tim Chase
On 07/25/12 12:47, Simon Pirschel wrote: > I'm currently experimenting with IMAP using Python 2.7.3 and > IMAP4 from imaplib. I noticed the performance to be very bad. I > read 5000 files from a directory and append them to an IMAP > INBOX. The hole procedure of reading and appending is taking > ab

Re: OT: Text editors (was Re: Search and replace text in XML file?)

2012-07-28 Thread Tim Chase
On Sat, Jul 28, 2012 at 6:29 PM, Mark Lawrence wrote: > I highly recommend the use of notepad++. If anyone knows of a > better text editor for Windows please let me know :) I'll advocate for Vim which is crazy-powerful and works nicely on just about any platform I touch. Others will advocate for

Re: OT: Text editors

2012-07-29 Thread Tim Chase
On 07/29/12 05:28, Mark Lawrence wrote: > On 29/07/2012 06:08, Ben Finney wrote: >> Tim Chase writes: >> Learn one of Emacs or Vim well, and you won't need to worry >> about text editors again. > > Point taken, snag being I've never used any nix box in ang

Re: Is Python a commercial proposition ?

2012-07-29 Thread Tim Chase
On 07/29/12 12:13, Michael Hrivnak wrote: > - Operating system installer: http://fedoraproject.org/wiki/Anaconda > - Software repository management: http://pulpproject.org/ > - Software package installation: > http://en.wikipedia.org/wiki/Ubuntu_Software_Center > - Cloud computing: http://en.wikipe

Re: Is Python a commercial proposition ?

2012-07-30 Thread Tim Chase
On 07/29/12 21:31, Rodrick Brown wrote: > Its still not possible to be a pure Python developer and find > gainful employment today. I'm not sure where you get your facts, but unless you define "pure" in a super-narrow way, it's just flat-out wrong. I've been employed doing primarily Python for th

OT: accessibility (was "Re: simplified Python parsing question")

2012-07-30 Thread Tim Chase
On 07/30/12 21:11, Eric S. Johansson wrote: > the ability for multiple people to work on the same document at > the same time is really important. Can't do that with Word or > Libre office. revision tracking in traditional word processors > are unpleasant to work with especially if your hands a

Re: dbf.py API question

2012-08-03 Thread Tim Chase
On 08/03/12 08:11, Ethan Furman wrote: > So far all feedback is for the flag, so that's what I'll do. I agree with the flag, though would also be reasonably content with using None for the filename to indicate in-memory rather than on-disk storage. -tkc -- http://mail.python.org/mailman/list

Re: when an iterable object is exhausted or not

2012-08-04 Thread Tim Chase
On 08/04/12 14:20, Franck Ditter wrote: > Two similar iterable objects but with a different behavior : > > $$$ i = range(2,5) > $$$ for x in i : print(x,end=' ') > > 2 3 4 > $$$ for x in i : print(x,end=' ')# i is not exhausted > > 2 3 4 > > - Compare with : > > $$$ i = fi

Re: Intermediate Python user needed help

2012-08-05 Thread Tim Chase
On 08/05/12 15:52, John Mordecai Dildy wrote: > Current Problem at the moment > > Traceback (most recent call last): > File "ex26.py", line 66, in > beans, jars, crates = secret_formula(start-point) > NameError: name 'start' is not defined > > anyone know how to make start defined "start-

Re: Intermediate Python user needed help

2012-08-05 Thread Tim Chase
On 08/05/12 17:00, John Mordecai Dildy wrote: > since when did we start talking about lisp? Though not a lisper, the Python tie-in was my reply: Python (among many other languages) doesn't allow a "-" as a character in identifiers as you appeared to use it in your code. Unlike HTML, XML, CSS, an

Re: Intermediate Python user needed help

2012-08-05 Thread Tim Chase
On 08/05/12 16:32, Roy Smith wrote: > Tim Chase wrote: >> You either mean something like "start_point" (with an underscore >> instead of a minus), or you're performing a subtraction of "start >> minus point", in which case you'd have to ass

Re: Intermediate Python user needed help

2012-08-05 Thread Tim Chase
On 08/05/12 20:15, Dennis Lee Bieber wrote: > On Sun, 05 Aug 2012 19:32:26 -0400, Roy Smith declaimed >>> Though not a lisper, the Python tie-in was my reply: Python (among >>> many other languages) doesn't allow a "-" as a character in >>> identifiers as you appeared to use it in your code. Unl

Re: save dictionary to a file without brackets.

2012-08-09 Thread Tim Chase
On 08/09/12 15:22, Roman Vashkevich wrote: >> {(4, 5): 1, (5, 4): 1, (4, 4): 2, (2, 3): 1, (4, 3): 2} >> and i want to print to a file without the brackets comas and semicolon in >> order to obtain something like this? >> 4 5 1 >> 5 4 1 >> 4 4 2 >> 2 3 1 >> 4 3 2 > > for key in dict: > prin

Re: save dictionary to a file without brackets.

2012-08-09 Thread Tim Chase
On 08/09/12 15:41, Roman Vashkevich wrote: > 10.08.2012, в 0:35, Tim Chase написал(а): >> On 08/09/12 15:22, Roman Vashkevich wrote: >>>> {(4, 5): 1, (5, 4): 1, (4, 4): 2, (2, 3): 1, (4, 3): 2} >>>> and i want to print to a file without the brackets comas and s

Re: save dictionary to a file without brackets.

2012-08-09 Thread Tim Chase
On 08/09/12 17:26, Dave Angel wrote: > On 08/09/2012 06:03 PM, Andrew Cooper wrote: > I'm glad you're wrong for CPython's dictionaries. The only time the > lookup would degenerate to O[n] would be if the hash table had only one > slot. CPython sensibly increases the hash table size when it become

Re: save dictionary to a file without brackets.

2012-08-09 Thread Tim Chase
On 08/09/12 18:33, Mark Lawrence wrote: > On 10/08/2012 00:24, Roy Smith wrote: >>> ... you mean, Python lets you make a hash of it? >> >> Only if you order it with spam, spam, spam, spam, spam, spam, and spam. > > Now now gentlemen we're getting slightly off topic here and wouldn't > want to ups

Re: Unable to execute the script

2012-08-10 Thread Tim Chase
On 08/10/12 13:38, Dave Angel wrote: > On 08/10/2012 01:14 PM, Smaran Harihar wrote: >> Hi, >> >> I have set executable permissions for my py script (cgi-script) but for >> some reason rather than executing it, the browser simply downloads the py >> script. >> >> Here is the >> link

Re: Unable to execute the script

2012-08-10 Thread Tim Chase
On 08/10/12 14:14, Smaran Harihar wrote: > If you mean chmod +x > > then yes it has been set. I'm not sure how Ubuntu defaults if you don't specify *who* should receive those +x permissions. I'd make sure they've been set for everybody: $ chmod ugo+x myfile.py You can check this by doing an

Re: dbf.py API question concerning Index.index_search()

2012-08-15 Thread Tim Chase
On 08/15/12 18:26, Ethan Furman wrote: >.index_search( > match, > start=None, > stop=None, > nearest=False, > partial=False ) > > The defaults are to search the entire index for exact matches and raise > NotFoundError if it can't find anything. > > The question i

Re: dbf.py API question concerning Index.index_search()

2012-08-15 Thread Tim Chase
On 08/15/12 19:21, Ethan Furman wrote: > The well-hidden clue was this line: > > nearest returns where the match should be instead of raising an error > > And my question should have been: > >What should the return value be when nearest == True? Ah, well that's somewhat clearer. Return the

Re: asking

2012-08-22 Thread Tim Chase
On 08/22/12 04:42, alex23 wrote: > On 08/22/2012 03:17 AM, mingqiang hu wrote: >> I mean any of "a","b","c" in string "adfbdfc" makes the statement true,can >> I not use a function? > > any(map(string.__contains__, substrings)) As map()/reduce() vs. list-comprehension discussions are going on in

Python list archives double-gzipped?

2012-08-26 Thread Tim Chase
Playing around with the mbox module, I reached into the archives[1] to grab some real-world data files[2]. To successfully unpack the contents to an mbox file, I had to do the following: bash$ gunzip 2012-July.txt.gz bash$ mv 2012-July.txt 2012-July.txt.gz bash$ gunzip 2012-July.txt.gz So

Re: Extract Text Table From File

2012-08-27 Thread Tim Chase
On 08/27/12 04:53, Huso wrote: > Below is just ONE block of the traffic i have in the log files. There will be > more in them with different data. > > ROUTES TRAFFIC RESULTS, LSR > TRG MP DATE TIME > 37 17 120824 > > R TRAFF NBIDS CCONG NDV ANBLO MHTIME NBANSW > A

Re: Python list archives double-gzipped?

2012-08-27 Thread Tim Chase
On 08/27/12 08:52, Andreas Perstinger wrote: > On 27.08.2012 03:40, Tim Chase wrote: >> So it looks like some python-list@ archiving process is double >> gzip'ing the archives. Can anybody else confirm this and get the >> info the right people? > > If you send the

Re: Python list archives double-gzipped?

2012-08-27 Thread Tim Chase
On 08/27/12 12:21, Ned Deily wrote: > In article <503ba5f0.3020...@tim.thechases.com>, Tim Chase > wrote: >> To whomever controls the python.org web-server, is it possible >> to tweak Apache so that it doesn't try to gzip *.gz files? It >> may ameliorate th

mailbox.mbox Status/X-Status flags RFC?

2012-08-30 Thread Tim Chase
Playing around with mailbox.mbox, I noticed the flag get split across Status/X-Status headers. I dug into the source and read at [1] to see the *how* but I'm curious as to the *why*. When I pulled up RFC-4155[2] (mbox), it didn't seem to mention anything about the Status/X-Status stuff, and the M

Re: thanks! (was "Test message - please ignore")

2012-08-31 Thread Tim Chase
On 08/31/12 09:15, Skip Montanaro wrote: > We just upgraded the Mailman installation on mail.python.org. Part of that > installation includes spam filtering on messages gated from Usenet to the > python- > l...@python.org mailing list. This message is a quick test of that function. > > You c

Re: how to get character hex number?

2012-08-31 Thread Tim Chase
On 08/31/12 21:21, contro opinion wrote: for i in "english" : > ... print(hex((ord(i > ... > 0x65 > 0x6e > 0x67 > 0x6c > 0x69 > 0x73 > 0x68 u"english".encode("utf-8") > 'english' u"english".encode("ascii") > 'english' > > how can i get 656e676c697368 in encode method? At leas

Re: how to get character hex number?

2012-08-31 Thread Tim Chase
On 08/31/12 22:41, contro opinion wrote: >> u"english".encode("utf-8") >>> 'english' >> u"english".encode("ascii") >>> 'english' >>> >>> how can i get 656e676c697368 in encode method? >> >> At least in 2.x, you can do: >> >> >>> u"english".encode("hex") >> '656e676c697368' > > how about i

Re: how to get character hex number?

2012-09-01 Thread Tim Chase
On 09/01/12 03:49, Mark Lawrence wrote: > On 01/09/2012 04:50, Tim Chase wrote: >> Well, in 3.1.3 at least, using the u"..." notation dies on me with >> an invalid syntax. > > The u"..." notation has been reintroducd for Python 3.3 Nice to know--it makes

Re: Extract Text Table From File

2012-09-05 Thread Tim Chase
[trimming out a bunch of superfluous text so the thread is actually readable] On 09/05/12 08:08, Ramchandra Apte wrote: > On Monday, 27 August 2012 15:42:14 UTC+5:30, Laszlo Nagy wrote: >> On 2012-08-27 11:53, Huso wrote: >>> I am trying to extract some text table data from a log file >> >> fin =

Re: is implemented with id ?

2012-09-05 Thread Tim Chase
On 09/05/12 08:46, Dave Angel wrote: > It's id() which is superfluous. But it's useful for debugging, > and for understanding. While I assiduously work to eschew shadowing most built-in names such as "list" or "str", I do make an exception for "id" because it's *so* useful in code, and the built-

Re: simple client data base

2012-09-09 Thread Tim Chase
On 09/08/12 14:47, Mark R Rivet wrote: > Well I have to say that this is most discouraging. I should give > up learning to program. I don't have a chance at all. Thanks. I think the intent is not to deter you from learning to program, but rather to urge you in a direction less fraught with peril.

Re: Single leading dash in member variable names?

2012-09-12 Thread Tim Chase
On 09/12/12 00:10, Dwight Hutto wrote: > Not to jump in with another question(this seems somewhat relevant > to the conversation, maybe not), but is this similar to a > private,public, or protected class similar to the C type langs? Close, but C-like languages tend to strictly enforce it, while in

Re: Boolean function on variable-length lists

2012-09-12 Thread Tim Chase
On 09/12/12 08:02, Jussi Piitulainen wrote: > Libra writes: >> For example, I may have a list L = [1, 2, 3, 4] and the following >> constraints: >> L[0] >= 1 >> L[1] <= 3 >> L[2] == 2 >> L[3] >= 3 > > So you would associate each constraint with an index. You could > maintain a list of constraints

  1   2   3   4   5   6   7   8   9   10   >