Re: Urgent - Would like to see output of each block of python

2016-06-06 Thread Chris Rebert
On Sun, Jun 5, 2016 at 11:57 PM, Archana Sonavane wrote: > Hi Team, > > I don't have any idea about python scripts, i have ganglia tool python > scripts. > > I would like see the output of each code block, could you please guide. > > The code as follows: With regard to your Subject line, please

Re: python domain in China. This showed up on Python list

2015-12-01 Thread Chris Rebert
On Tue, Dec 1, 2015 at 2:10 AM, Laura Creighton wrote: > I think we have just dodged a bullet, let us now go thank the > nice people who sent us this and figure out how we should > secure the domain. > > Laura > > > --- Forwarded Message > > Return-Path: > Date: Tue, 1 Dec 2015 15:12:58 +0800

Re: more itertools

2015-08-31 Thread Chris Rebert
On Mon, Aug 31, 2015 at 6:42 PM, Mark Lawrence wrote: > This contained the itertool recipes and was available on pypi but looks like > it's gone. Can anybody tell me if it's defunct, superseded or what? What do you mean? It's still there AFAICT: https://pypi.python.org/pypi/more-itertools St

Re: Python/Github

2015-08-24 Thread Chris Rebert
On Mon, Aug 24, 2015 at 1:14 PM, DBS wrote: > Hello, > > I'm trying to retrieve the number of commits and changed files on all pull > requests submitted to a branch. > > The call to get all the pull requests is GET /repos/:owner/:repo/pulls, but > it does not return "commits" or "changed_files".

Re: looking for standard/builtin dict-like data object

2015-08-10 Thread Chris Rebert
On Mon, Aug 10, 2015 at 8:22 PM, Vladimir Ignatov wrote: > Hi, > > In my code I often use my own home-brewed object for passing bunch of > data between functions. Something like: > > class Data(object): > def __init__ (self, **kwargs): > self.__dict__ = kwargs > > > > return Data(

Re: Decimals and other numbers

2015-01-08 Thread Chris Rebert
On Thu, Jan 8, 2015 at 6:33 PM, Devin Jeanpierre wrote: > I noticed some very PHP-ish behavior today: > import decimal x = 0 y = float(x) z = decimal.Decimal(x) x == y == z == x > True x ** x > 1 y**y > 1.0 z**z > Traceback (most recent call last): > File

Re: Import Doesn't Import

2014-10-15 Thread Chris Rebert
On Wednesday, October 15, 2014, ryguy7272 wrote: > So sorry everyone. I've posted here several times today. This is VERY > frustrating. > > So, I'm reading this link. > https://docs.python.org/2/howto/urllib2.html > > Important note!: The "/2/" in the URL means those docs are for Python 2.x Wh

Re: Linux distros w/o Python in "base" installation

2014-08-11 Thread Chris Rebert
On Mon, Aug 11, 2014 at 11:53 AM, Grant Edwards wrote: > I just installed Arch Linux for the first time, and was surprosed to > find that Python isn't installed as part of a "base" system. It's > also not included in the 'base-devel' package group. It's trivial to > install, but I'd still pretty

Re: Distributing python applications as a zip file

2014-07-22 Thread Chris Rebert
On Tue, Jul 22, 2014 at 9:23 PM, Steven D'Aprano wrote: > A little known feature of Python: you can wrap your Python application in > a zip file and distribute it as a single file. The trick to make it > runnable is to put your main function inside a file called __main__.py > inside the zip file.

Re: UTC "timezone" causing brain explosions

2014-01-29 Thread Chris Rebert
On Wed, Jan 29, 2014 at 1:52 PM, Skip Montanaro wrote: > Following up on my earlier note about UTC v. GMT, I am having some > trouble grokking attempts to convert a datetime into UTC. Consider > these three values: > import pytz UTC = pytz.timezone("UTC") LOCAL_TZ = pytz.timezone("A

Re: Re: Postfix conditionals

2014-01-05 Thread Chris Rebert
on that I have posted > to python-list@python.org, so I am forwarding it to here. > Original Message > Subject: Re: Postfix conditionals > Date: Sun, 5 Jan 2014 14:09:14 -0800 > From: Chris Rebert > To: Göktuğ Kayaalp > CC: Python -- https://mail.pyth

Re: Postfix conditionals

2014-01-05 Thread Chris Rebert
On Sun, Jan 5, 2014 at 12:24 PM, Göktuğ Kayaalp wrote: > Hi, > > AFAIK, we do not have "postfix conditionals" in Python, i.e. a condition > appended to a > statement, which determines whether the statement runs or not: > > py> for i in [False]: > ... break if not i > > The above piece of c

Re: a Python Static Analyzer

2013-12-14 Thread Chris Rebert
On Sat, Dec 14, 2013 at 5:31 PM, Dan Stromberg wrote: > Where does PySonar2 sit in the spectrum from pylint > (thorough/pedantic) to pyflakes (relaxed/few-false-positives)? > > I use pylint and pyflakes a lot, and I've heard that PyChecker sits in > between them on this axis. My impression is tha

Re: How to parse JSON passed on the command line?

2013-11-06 Thread Chris Rebert
On Wed, Nov 6, 2013 at 7:53 PM, Anthony Papillion wrote: > Hello Everyone, > > I'm writing a little helper script in Python that will access a JSON > formatted argument from the shell when it's called. The parameter will > look like this: > > {"url":"http://www.google.com"} > > So, if my program i

Re: I am never going to complain about Python again

2013-10-09 Thread Chris Rebert
On Wed, Oct 9, 2013 at 9:36 PM, Steven D'Aprano wrote: > Just came across this little Javascript gem: > > ",,," == Array((null,'cool',false,NaN,4)); > > => evaluates as true > > http://wtfjs.com/2011/02/11/all-your-commas-are-belong-to-Array > > I swear, I am never going to complain about Python a

Re: Language design

2013-09-10 Thread Chris Rebert
* No explicit variable declarations (modulo `global`+`nonlocal`) means that variable name typos can't be reliably detected at compile-time. * The value of the loop variable at call-time for functions defined within a loop trips people up. * No self-balancing tree datatype of any kind is included in

Re: Looking for a name for a deployment framework...

2013-06-24 Thread Chris Rebert
On Jun 24, 2013 5:36 AM, wrote: > > Hi all, > > Any suggestions for a good name, for a framework that does automatic server deployments? > > It's like Fabric, but more powerful. > It has some similarities with Puppet, Chef and Saltstack, but is written in Python. Er, Salt is likewise written in P

Re: Newbie: The philosophy behind list indexes

2013-06-14 Thread Chris Rebert
On Jun 14, 2013 10:26 PM, wrote: > I bet this is asked quite frequently, however after quite a few hours searching I haven't found an answer. > > What is the thinking behind stopping 'one short' when slicing or iterating through lists? > > By example; > > >>> a=[0,1,2,3,4,5,6] > >>> a > [0, 1, 2,

Re: Popen and reading stdout in windows

2013-06-11 Thread Chris Rebert
On Jun 11, 2013 12:21 AM, "Pete Forman" wrote: > > "Joseph L. Casale" writes: > > >> You leave out an awful amount of detail. I have no idea what ST is, > >> so I'll have to guess your real problem. > > > > Ugh, sorry guys its been one of those days, the post was rather > > useless... > > > > I a

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

2013-06-10 Thread Chris Rebert
On Mon, Jun 10, 2013 at 1:34 PM, Roy Smith wrote: > I have a list, songs, which I want to divide into two groups. > Essentially, I want: > > new_songs = [s for s in songs if s.is_new()] > old_songs = [s for s in songs if not s.is_new()] > > but I don't want to make two passes over the list. I cou

Re: Finding Relative Maxima in Python3

2013-05-31 Thread Chris Rebert
On May 31, 2013 2:46 AM, "Lourens-Jan Ugen" wrote: > > Hi all, > > The last few days I've been working on a script to manipulate some scientific data. One thing I would like to be able to do is find relative maxima in a data set. > I'm using numpy in python3 (which I think I can't do without becau

Re: Piping processes works with 'shell = True' but not otherwise.

2013-05-29 Thread Chris Rebert
On Sun, May 26, 2013 at 4:58 PM, Luca Cerone wrote: > Hi Chris, first of all thanks for the help. Unfortunately I can't provide the > actual commands because are tools that are not publicly available. > I think I get the tokenization right, though.. the problem is not that the > programs don't

Re: detect key conflict in a JSON file

2013-05-29 Thread Chris Rebert
On Wed, May 29, 2013 at 4:16 AM, Jabba Laci wrote: > Hi, > > How can you detect if a key is duplicated in a JSON file? Example: > > { > "something": [...], > ... > "something": [...] > } > > I have a growing JSON file that I edit manually and it might happen > that I repeat a key. If t

Re: Piping processes works with 'shell = True' but not otherwise.

2013-05-26 Thread Chris Rebert
On May 24, 2013 7:06 AM, "Luca Cerone" wrote: > > Hi everybody, > I am new to the group (and relatively new to Python) > so I am sorry if this issues has been discussed (although searching for topics in the group I couldn't find a solution to my problem). > > I am using Python 2.7.3 to analyse the

Re: serialize a class to XML and back

2013-05-26 Thread Chris Rebert
On May 23, 2013 3:42 AM, "Schneider" wrote: > > Hi list, > > how can I serialize a python class to XML? Plus a way to get the class back from the XML? There's pyxser: http://pythonhosted.org/pyxser/ > My aim is to store instances of this class in a database. Honestly, I would avoid XML if you c

Re: Source code as text/plain

2013-05-24 Thread Chris Rebert
On May 24, 2013 9:02 PM, "Carlos Nepomuceno" wrote: > > I'd like to have the option to download the source code as text/plain from the docs.python.org pages. > > For example: when I'm a docs page, such as: > > http://docs.python.org/2/library/string.html > > and I click the source code link I'm ta

Re: There must be a better way

2013-04-20 Thread Chris Rebert
On Sat, Apr 20, 2013 at 4:46 PM, Colin J. Williams wrote: > Below is part of a script which shows the changes made to permit the script > to run on either Python 2.7 or Python 3.2. > > I was surprised to see that the CSV next method is no longer available. > > Suggestions welcome. > if ver ==

Re: The type/object distinction and possible synthesis of OOP and imperative programming languages

2013-04-17 Thread Chris Rebert
On Tue, Apr 16, 2013 at 11:40 PM, Steven D'Aprano wrote: > On Tue, 16 Apr 2013 15:38:29 -0700, Mark Janssen wrote: > > (Note this contrasts starkly with Java(script), which doesn't seem > > to be based on anything -- can anyone clarify where Java actually comes > > from?) > > C. "Influenced by

Re: Calling python script in dos and passing arguments

2013-04-16 Thread Chris Rebert
On Tue, Apr 16, 2013 at 7:14 AM, PEnergy wrote: > Greetings, > > I am trying to write a python script that, when called from the DOS prompt, > will call another python script and pass it input variables. My current code > will open the other python script but doesn't seem to pass it any values:

Re: Threadpool item mailboxes design problem

2013-04-14 Thread Chris Rebert
On Apr 14, 2013 4:27 PM, "Charles Hixson" wrote: > > What is the best approach to implementing actors that accept and post messages (and have no other external contacts). You might look at how some of the existing Python actor libraries are implemented (perhaps one of these might even save you fr

Re: os.system() with imbeded quotes on centos

2013-04-05 Thread Chris Rebert
On Fri, Apr 5, 2013 at 3:00 PM, Cameron Simpson wrote: > On 01Apr2013 20:26, John Gordon wrote: > | In <0c9717ca-52dd-49ce-8102-e14328838...@googlegroups.com> cev...@gmail.com > writes: > | > someip = '192.168.01.01' > | > var1 = 'lynx -dump http://' + someip + > '/cgi-bin/.log&.submit=+++G

Re: Curl and python httplib?

2013-03-28 Thread Chris Rebert
On Wed, Mar 27, 2013 at 7:54 PM, 小学园PHP wrote: > Guys, > > I take a project that need send request to Hadoop by curl. > But now, the curl and pycurl can't satisfy my project. So i need use the > powerful httplib. I would say that `requests` (http://docs.python-requests.org/en/latest/ ) is general

Re: Doing both regex match and assignment within a If loop?

2013-03-28 Thread Chris Rebert
On Thu, Mar 28, 2013 at 9:00 PM, Victor Hooi wrote: > Hi, > > I have logline that I need to test against multiple regexes. E.g.: > > import re > > expression1 = re.compile(r'') > expression2 = re.compile(r'') > > with open('log.txt') as f: > for line in f: >

Re: OOPv2: [Was: Message passing syntax for objects]

2013-03-19 Thread Chris Rebert
On Tue, Mar 19, 2013 at 9:46 PM, Mark Janssen wrote: > Hopefully this won't be considered mail spam, but another quora answer that > gets to the idea I'm after: http://qr.ae/TMh7A > > Reposted here for those who don't have accounts: > > Q. Is it time for us to dump the OOP paradigm? If yes, what

Re: TypeError: 'float' object is not iterable

2013-03-14 Thread Chris Rebert
On Thu, Mar 14, 2013 at 3:12 AM, Ana Dionísio wrote: > Hi!! > > I keep having this error and I don't know why: TypeError: 'float' object is > not iterable. In general, in the future, always include the full exception Traceback, not just the final error message. The extra details this provides ca

Re: iterating over a list as if it were a circular list

2013-03-07 Thread Chris Rebert
On Mar 7, 2013 1:29 AM, "Sven" wrote: > > Stupid keyboard shortcuts, sent it too early. Apologies > > > I was wondering what the best approach for the following might be. > > Say you have a list P of points and another list N of other items. You can always assume that > > len(N) <= len(P) > > Now

Re: iterating over a list as if it were a circular list

2013-03-07 Thread Chris Rebert
On Mar 7, 2013 1:24 AM, "Sven" wrote: > > I was wondering what the best approach for the following might be. > > Say you have a list P of points and another list N of other items. You can always assume that > > len(N) <= len(P) > > Now I would like to iterate over P and place one N at each point.

Re: Unhelpful traceback

2013-03-06 Thread Chris Rebert
On Wed, Mar 6, 2013 at 10:33 PM, John Nagle wrote: > Here's a traceback that's not helping: > UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in > position 14: ordinal not in range(128) > The program is converting some .CSV files that come packaged in .ZIP > files. The files ar

Re: Insert comma in number?

2013-03-06 Thread Chris Rebert
On Wed, Mar 6, 2013 at 3:39 PM, eli m wrote: > I have a python program that accepts input and calculates the factorial of > that number, and i want to know if i can make it so commas get inserted in > the number. > For example: instead of 1000 it would say 1,000 Use the "," (i.e. comma) format(

Re: In win32 and linux platform, os modules has diffreent output order, is it a bug?

2013-03-01 Thread Chris Rebert
On Fri, Mar 1, 2013 at 12:43 AM, Honghe Wu wrote: > env: python 2.7.3 > > 6 test files' name in a directory as below: > 12ab Abc Eab a1bc acd bc > > the following is test code: > for root, dirs, files in os.walk(os.getcwd()): > print files > > the output in win32 platform is: > ['12ab', '

Re: Searching for a replacement for PIL

2013-02-26 Thread Chris Rebert
On Tue, Feb 26, 2013 at 10:17 PM, Thorsten Kiefer wrote: > Hi, > my actual program imports ImageTk, to generate TK compatible images. > But it seems like PIL is no longer supported. Have you investigated the Pillow fork? https://pypi.python.org/pypi/Pillow/ Cheers, Chris -- http://mail.python.o

Re: using urllib on a more complex site

2013-02-24 Thread Chris Rebert
On Sunday, February 24, 2013, Adam W. wrote: > I'm trying to write a simple script to scrape > http://www.vudu.com/movies/#tag/99centOfTheDay/99c%20Rental%20of%20the%20day > > in order to send myself an email every day of the 99c movie of the day. > > However, using a simple command like (in Pytho

Re: webbrowser.open("./documentation/help.html")-- No Go in Windows

2013-02-24 Thread Chris Rebert
On Sun, Feb 24, 2013 at 12:28 PM, llanitedave wrote: > On Sunday, February 24, 2013 1:35:31 AM UTC-8, Chris Rebert wrote: >> On Feb 24, 2013 1:21 AM, "llanitedave" wrote: >> > I created an html help page for my Python 2.7.3 application and put it in >>

Re: webbrowser.open("./documentation/help.html")-- No Go in Windows

2013-02-24 Thread Chris Rebert
On Feb 24, 2013 1:21 AM, "llanitedave" wrote: > > I created an html help page for my Python 2.7.3 application and put it in a documentation folder. I used webbrowser.open() to fetch the page. > > On linux -- KDE specifically, the command opens the local file on my default browser with no issues.

Re: webbrowser.open("./documentation/help.html")-- No Go in Windows

2013-02-24 Thread Chris Rebert
On Feb 24, 2013 1:21 AM, "llanitedave" wrote: > > I created an html help page for my Python 2.7.3 application and put it in a documentation folder. I used webbrowser.open() to fetch the page. > > On linux -- KDE specifically, the command opens the local file on my default browser with no issues.

Re: Python scheduler

2013-02-20 Thread Chris Rebert
On Wed, Feb 20, 2013 at 8:04 PM, Rita wrote: > Hello, > > Here is what I am trying to do. (Currently, I am doing this in cron but i > need much more granularity). I am trying to run program every 20 secs and > loop forever. I have several of these types of processes, some should run > every 5 mins

Re: Calendar module question

2013-02-17 Thread Chris Rebert
On Saturday, February 16, 2013, Phil wrote: > Thank you for reading this. > > My adventures with Python have just begun and during the few weeks I have > tried many IDEs. The following piece of code fails under all IDEs, and the > interpreter, except under the Wing IDE. > > Why would this code wor

Re: Python trademark under attack -- the PSF needs your help

2013-02-15 Thread Chris Rebert
On Feb 15, 2013 8:13 AM, "Jason Swails" wrote: > I'm not offering much help here, more like wondering aloud. Doesn't Google (not to mention other software companies) have an interest staked in binding the Python name with the Python language? I can't imagine python.co.uk staging a successful ca

Re: call shell from python

2013-02-11 Thread Chris Rebert
On Mon, Feb 11, 2013 at 9:13 PM, contro opinion wrote: import os os.system("i=3") > 0 os.system("echo $i") > > 0 > how can i get the value of i? Your example is too heavily contrived for me to give a much more specific/useful answer than "use the `subprocess` module": http://docs.

Re: Alternative to Apache+mod_fcgid+Flup?

2013-02-11 Thread Chris Rebert
On Feb 11, 2013 6:16 AM, "Gilles" wrote: > > Hello > > I read this article... > > "Why is WSGI deployment under FASTCGI so painful?" > http://blog.dscpl.com.au/2011/09/why-is-wsgi-deployment-under-fastcgi-so.html > > ... and was wondering what better alternative is available to run > Python web sc

Re: cafebabe python macosx easter egg?

2013-02-10 Thread Chris Rebert
On Sun, Feb 10, 2013 at 10:10 PM, Rodrick Brown wrote: > Subject: cafebabe python macosx easter egg? > > $ hexdump -n4 -C $(which python) | awk '{print $2 $3 $4 $5 }' cafebabe ~ $ # Huh. Let's google... http://en.wikipedia.org/wiki/Hexspeak : "0xCAFEBABE ("cafe babe") is used by Mach-O to identif

Re: Floating point calculation problem

2013-02-02 Thread Chris Rebert
On Sat, Feb 2, 2013 at 2:27 AM, Schizoid Man wrote: > I have a program that performs some calculations that runs perfectly on > Python 2.7.3. However, when I try to execute it on Python 3.3.0 I get the > following error: >numer = math.log(s) > TypeError: a float is required > > The quantity s

Re: how to use subprocess to execute an exe with args and an output

2013-01-30 Thread Chris Rebert
On Wed, Jan 30, 2013 at 9:15 AM, noydb wrote: > I am looking for some guidance on using subprocess to execute an EXE with > arguments and an output. The below code works in that it returns a 0 exit > code, but no output file is created. I have tried a few different versions > of this code (us

Re: security quirk

2013-01-29 Thread Chris Rebert
On Tue, Jan 29, 2013 at 8:55 PM, RichD wrote: > I read Wall Street Journal, and occasionally check > articles on their Web site. It's mostly free, with some items > available to subscribers only. It seems random, which ones > they block, about 20%. > > Anywho, sometimes I use their search utilit

Re: Split string data have ","

2013-01-29 Thread Chris Rebert
On Jan 29, 2013 9:05 AM, "moonhkt" wrote: > > Hi All > > Python 2.6.2 on AIX 5.3 > How to using split o > > >>> y = '"abc.p,zip.p",a,b' > >>> print y > "abc.p,zip.p",a,b > >>> > > >>> k= y.split(",") > >>> print k[0] > "abc.p > >>> > > Need Result, First element is > abc.p,zip.p Try the csv modul

Re: Increase value in hash table

2013-01-22 Thread Chris Rebert
On Jan 22, 2013 11:31 PM, "moonhkt" wrote: > > Hi Al > > I have Data file have below > > Data file > V1 > V2 > V3 > V4 > V4 > V3 > > How to using count number of data ? > > Output > V1 = 1 > V2 = 1 > V3 =2 > V4 = 2 Construct a frequency table using collections.Counter: http://docs.python.org/2.7

Re: Safely add a key to a dict only if it does not already exist?

2013-01-18 Thread Chris Rebert
On Friday, January 18, 2013, Steven D'Aprano wrote: > I wish to add a key to a dict only if it doesn't already exist, but do it > in a thread-safe manner. > > The naive code is: > > if key not in dict: > dict[key] = value > > > but of course there is a race condition there: it is possible that

Re: License status of pycollada?

2013-01-07 Thread Chris Rebert
On Sunday, January 6, 2013, Gene Heskett wrote: > Greetings all; > > Trying to collect all the dependencies of FreeCad-0.13, but it appears that > pycollada is behind some sort of a login/paywall on github. Is anyone here > familiar with how that works? > Er, what? The repo seems freely browseab

Re: os.path.realpath(path) bug on win7 ?

2013-01-05 Thread Chris Rebert
On Sat, Jan 5, 2013 at 10:55 PM, iMath <2281570...@qq.com> wrote: > > os.path.realpath(path) bug on win7 ? > > Temp.link is a Symbolic link > Its target location is C:\test\test1 > But > >>> os.path.realpath(r'C:\Users\SAMSUNG\Temp.link\test2') > 'C:\\Users\\SAMSUNG\\Temp.link\\test2' > > I though

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

2013-01-03 Thread Chris Rebert
On Thu, Jan 3, 2013 at 3:25 PM, Grant Edwards wrote: > > I've written a small assembler in Python 2.[67], and it needs to > evaluate integer-valued arithmetic expressions in the context of a > symbol table that defines integer values for a set of names. The > "right" thing is probably an expressi

Re: pylint, was Re: pygame - importing GL - very bad...

2013-01-02 Thread Chris Rebert
On Wed, Jan 2, 2013 at 10:01 PM, Ben Finney wrote: > Ian Kelly writes: > >> On Wed, Jan 2, 2013 at 7:24 PM, someone wrote: >> > 1) class somethingWork: Invalid name "somethingWork" (should match >> > [A-Z_][a-zA-Z0-9]+$), I'm not that good at regular exps, but I >> > suppose it wants my class na

Re: Handling Special characters in python

2013-01-02 Thread Chris Rebert
On Wed, Jan 2, 2013 at 5:39 AM, wrote: > On Wednesday, January 2, 2013 12:02:34 PM UTC+5:30, Chris Rebert wrote: >> On Jan 1, 2013 8:48 PM, wrote: >> > On Wednesday, January 2, 2013 12:00:06 AM UTC+5:30, Chris Rebert wrote: >> > > On Jan 1, 2013 3:41 AM, wrote:

Re: Handling Special characters in python

2013-01-01 Thread Chris Rebert
On Jan 1, 2013 8:48 PM, wrote: > On Wednesday, January 2, 2013 12:00:06 AM UTC+5:30, Chris Rebert wrote: > > On Jan 1, 2013 3:41 AM, wrote: > > > > > I am facing one issue in my module. I am gathering data from sql server database. In the data that I got from db contains

Re: Handling Special characters in python

2013-01-01 Thread Chris Rebert
On Jan 1, 2013 3:41 AM, wrote: > > I am facing one issue in my module. I am gathering data from sql server database. In the data that I got from db contains special characters like "endash". Python was taking it as "\x96". I require the same character(endash). How can I perform that. Can you pleas

Re: father class name

2012-12-31 Thread Chris Rebert
On Mon, Dec 31, 2012 at 1:23 AM, Ben Finney wrote: > Chris Rebert writes: > >> By contrast, in the first part of the *expression* >> `haha(object).theprint()`, you passed an argument (namely, `object`). >> Since __init__() wasn't expecting any arguments whatsoever,

Re: father class name

2012-12-30 Thread Chris Rebert
On Sun, Dec 30, 2012 at 8:18 PM, contro opinion wrote: > here is my haha class > class haha(object): > def theprint(self): > print "i am here" > haha().theprint() > i am here haha(object).theprint() > Traceback (most recent call last): > File "", line 1, in > TypeError: objec

Re: class problem

2012-12-30 Thread Chris Rebert
On Sun, Dec 30, 2012 at 10:36 PM, contro opinion wrote: > here is my haha class > class haha(object): > def theprint(self): > print "i am here" > haha().theprint() > i am here haha(object).theprint() > Traceback (most recent call last): > File "", line 1, in > TypeError: obje

Re: how to get the source of html in lxml?

2012-12-30 Thread Chris Rebert
On Sun, Dec 30, 2012 at 10:32 PM, contro opinion wrote: > import urllib > import lxml.html > down='http://blog.sina.com.cn/s/blog_71f3890901017hof.html' > file=urllib.urlopen(down).read() > root=lxml.html.document_fromstring(file) > body=root.xpath('//div[@class="articalContent "]')[0] > print bo

Re: email.message.Message - as_string fails

2012-12-28 Thread Chris Rebert
On Dec 28, 2012 4:26 AM, "Helmut Jarausch" wrote: > > Hi, > > I'm trying to filter an mbox file by removing some messages. > For that I use > Parser= FeedParser(policy=policy.SMTP) > and 'feed' any lines to it. > If the mbox file contains a white line followed by '^From ', > I do > > Msg= Parser.c

Re: Finding the name of a function while defining it

2012-12-27 Thread Chris Rebert
On Dec 26, 2012 11:55 PM, "Abhas Bhattacharya" wrote: > > On Thursday, 27 December 2012 10:22:15 UTC+5:30, Tim Roberts wrote: > > Abhas Bhattacharya wrote: > > [Oh god please stop/avoid using Google Groups with its godawful reply-quoting style that adds excessive blank lines] > > >While I am def

Re: Finding the name of a function while defining it

2012-12-27 Thread Chris Rebert
On Dec 25, 2012 6:06 PM, "Abhas Bhattacharya" wrote: > > While I am defining a function, how can I access the name (separately as string as well as object) of the function without explicitly naming it(hard-coding the name)? > For eg. I am writing like: > def abc(): > #how do i access the funct

Re: How to get time.strptime()?

2012-12-26 Thread Chris Rebert
On Wednesday, December 26, 2012, Gnarlodious wrote: > Error: AttributeError: 'module' object has no attribute '_strptime' > Please include the full Traceback, not just the final error message. This problem is driving me crazy. It only happens in Python 3.3.0, while on > my server running 3.1.3

Re: pygnomevfs get_local_path_from_uri replacement

2012-12-22 Thread Chris Rebert
On Sat, Dec 22, 2012 at 12:57 AM, Daniel Fetchinson wrote: > Hi folks, I realize this is slightly off topic and maybe belongs to a > gnome email list but it's nevertheless python: > > I use an old python program that was written for gnome 2 and gtk 2 and > uses the function get_local_path_from_uri

Re: Pexpect and buffering

2012-12-15 Thread Chris Rebert
On Dec 15, 2012 4:51 AM, wrote: > > Hello, > > I'm trying to use pexpect to grab interactions with Python's REPL. I am having trouble with tracebacks. Possibly it is related to buffering (hence the subject line) but I admit that's a guess. Why are you doing this in the first place? Why invoke a

Re: JSON logging ?

2012-12-12 Thread Chris Rebert
On Dec 11, 2012 7:33 AM, "Bart Thate" wrote: > pickle uses eval still ? or is is considered safe now ? i was told not to use eval() stuff on data. I don't believe pickle uses eval() per se, but per the red warning box in its docs, it's still not safe when given untrusted input. IIRC, among other

Re: Is __ne__ method autogenerated?

2012-12-06 Thread Chris Rebert
On Thursday, December 6, 2012, INADA Naoki wrote: > The reference says: > > The truth of x==y does not imply that x!=y is false. > Accordingly, when defining __eq__(), one should also > define __ne__() so that the operators will behave as expected. > > (http://docs.python.org/3/reference/dat

Re: how to pass "echo t | " input to subprocess.check_output() method

2012-11-26 Thread Chris Rebert
On Nov 26, 2012 3:03 AM, "Kushal Kumaran" wrote: > dacha...@gmail.com writes: > > I want to list the repositories in svn using python. For this i have used below command, > > " res = subprocess.check_output(["svn.exe", "list", " Https://127.0.0.1:443/svn/Repos"], stderr=subprocess.STDOUT) " > > >

Re: how to pass "echo t | " input to subprocess.check_output() method

2012-11-26 Thread Chris Rebert
On Nov 26, 2012 2:41 AM, wrote: > > Hi all, > > I want to list the repositories in svn using python. For this i have used below command, > " res = subprocess.check_output(["svn.exe", "list", " Https://127.0.0.1:443/svn/Repos"], stderr=subprocess.STDOUT) " > > but it throws an exception, since it r

Re: mysql insert with tuple

2012-11-21 Thread Chris Rebert
On Wed, Nov 21, 2012 at 9:19 AM, Christian wrote: > Hi , > > my purpose is a generic insert via tuple , because the number of fields and > can differ. But I'm stucking . > > ilist=['hello',None,7,None,None] > > #This version works, but all varchar fields are in extra '' enclosed. > con.execute(

Re: Web Frameworks Excessive Complexity

2012-11-21 Thread Chris Rebert
On Wed, Nov 21, 2012 at 10:57 AM, rh wrote: > On Wed, 21 Nov 2012 10:12:26 -0800 > Chris Rebert wrote: >> On Wed, Nov 21, 2012 at 9:49 AM, rh >> wrote: >> > On Tue, 20 Nov 2012 20:41:42 +0300 >> > Andriy Kornatskyy wrote: >> > I'm looking at

Re: Constructing JSON data structures from non-string key python dictionaries

2012-11-21 Thread Chris Rebert
On Wed, Nov 21, 2012 at 7:48 AM, MRAB wrote: > On 2012-11-21 14:59, saikari78 wrote: >> >> Hi, >> >> I'm using the json module to create a JSON string, then inserting that >> string into a html template containing a javascript function (from the >> highcharts library: http://www.highcharts.com/)

Re: Web Frameworks Excessive Complexity

2012-11-21 Thread Chris Rebert
On Wed, Nov 21, 2012 at 9:49 AM, rh wrote: > On Tue, 20 Nov 2012 20:41:42 +0300 > Andriy Kornatskyy wrote: >> Cyclomatic (or conditional) complexity is a metric used to indicate >> the complexity of a source code. Excessive complexity is something >> that is beyond recommended level of 10 (thresh

Re: Splitting a line while keeping quoted items together

2012-11-19 Thread Chris Rebert
On Monday, November 19, 2012, wrote: > I am working on a cmd.Cmd-based program, and normally could just split the > string and get the right parts. > > Now I have a case where I could have two or three words in the string that > need to be grouped into the same thing. > > Then I realized that I'm

Re: Problem with subprocess.call and windows schtasks

2012-11-18 Thread Chris Rebert
On Sun, Nov 18, 2012 at 5:48 AM, Tom Borkin wrote: > Hi, > I have this code: > > #!\Python27\python > > 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([

Re: Executing .exe on a remote Windows machine

2012-11-08 Thread Chris Rebert
On Thursday, November 8, 2012, Kevin Holleran wrote: > On Thu, Nov 8, 2012 at 9:43 AM, Kevin Holleran > > > wrote: > >> My goodness psexec. >> >> thanks can't believe that didn't come to me... >> >> >> >> >> On Thu, Nov 8, 2012 at 9:31 AM, Tim Golden >> >> > wrote: >> >>> On 08/11/2012

Re: Multi-dimensional list initialization

2012-11-04 Thread Chris Rebert
On Sun, Nov 4, 2012 at 10:27 PM, Demian Brecht wrote: > So, here I was thinking "oh, this is a nice, easy way to initialize a 4D > matrix" (running 2.7.3, non-core libs not allowed): > > m = [[None] * 4] * 4 > > The way to get what I was after was: > > m = [[None] * 4, [None] * 4, [None] * 4, [No

Re: python-forum

2012-11-02 Thread Chris Rebert
On Fri, Nov 2, 2012 at 1:19 AM, Sacha Rook wrote: > Hi does anyone know where the python-form.org site has gone? Some googling suggests that it's under new management: http://mcompute.co.uk/showthread.php?tid=2161 But comp.lang.python/python-list is better anyway [ ;-) ], and you're already here

Re: Negative array indicies and slice()

2012-10-29 Thread Chris Rebert
On Mon, Oct 29, 2012 at 1:24 AM, wrote: > On Sunday, October 28, 2012 9:44:56 PM UTC-7, alex23 wrote: >> On Oct 29, 2:09 pm, Andrew wrote: >> class RangedSlicer(list): >> Then wrap your lists with your RangedSlicer class as needed. > > Hmmm... > > I began a test in an interactive shell: >>

Re: Negative array indicies and slice()

2012-10-29 Thread Chris Rebert
On Mon, Oct 29, 2012 at 1:08 AM, wrote: > On Sunday, October 28, 2012 10:14:03 PM UTC-7, Paul Rubin wrote: >> Andrew writes: > I'm getting very frustrated with the editor provided for this group... It > keeps posting prematurely, and putting my email in even when I tell it not to > each time;

Re: Negative array indicies and slice()

2012-10-29 Thread Chris Rebert
On Mon, Oct 29, 2012 at 12:54 AM, Andrew wrote: > On Sunday, October 28, 2012 9:26:01 PM UTC-7, Ian wrote: >> On Sun, Oct 28, 2012 at 10:00 PM, Andrew wrote: > The slice class when passed to __getitem__() was created to merely pass two > numbers and a stride to __getitem__; As far as I know s

Re: Numpy module

2012-10-28 Thread Chris Rebert
On Sun, Oct 28, 2012 at 10:40 PM, wrote: > I've learned a lot about Ubuntu just trying to install numpy for Python > 3.2.3. I've finally managed to put it in the Python3.2 directory but when I > try to import it, I still get there's "no module named numpy." There are > other modules in the sam

Re: Simple Python question for some

2012-10-28 Thread Chris Rebert
On Sun, Oct 28, 2012 at 4:51 PM, Mark L. Hotz wrote: > I have what I think should be a relatively simple question for someone who > is knowledgeable about Python. > > At the IDLE prompt, when I enter “b” > 99, it responds True. In fact, it > doesn’t matter which number is entered here, “b” is alwa

Re: Help understanding an Object Oriented Program example

2012-10-28 Thread Chris Rebert
On Sun, Oct 28, 2012 at 4:30 PM, goldtech wrote: > Hi, > > Trying to learn Python OOP. An example from a book, may not be > formated after sending post but: > > class Contact: > all_contacts = [] > def __init__(self, name, email): > self.name = name > self.email = email >

Re: fastest data / database format for reading large files

2012-10-28 Thread Chris Rebert
On Tue, Oct 16, 2012 at 11:35 AM, Pradipto Banerjee wrote: > I am working with a series of large files with sizes 4 to 10GB and may need > to read these files repeated. What data format (i.e. pickle, json, csv, etc.) > is considered the fastest for reading via python? Pickle /ought/ to be faste

Re: turn list of letters into an array of integers

2012-10-24 Thread Chris Rebert
On Wed, Oct 24, 2012 at 9:27 PM, seektime wrote: > On Tuesday, October 23, 2012 11:07:29 PM UTC-7, Chris Rebert wrote: >> P.S.: I'm guessing you obtained `L` from file.readlines() or similar; >> it is worth noting for future reference that the readlines() method is &g

Re: turn list of letters into an array of integers

2012-10-23 Thread Chris Rebert
On Tue, Oct 23, 2012 at 10:23 PM, seektime wrote: > Here's some example code. The input is a list which is a "matrix" of letters: >a b a >b b a > > and I'd like to turn this into a Python array: You mean a Python list. The datatype Python calls an `array` is very different and relativ

Re: Remove uncide notation

2012-10-18 Thread Chris Rebert
On Thu, Oct 18, 2012 at 2:27 AM, Ashish Jain wrote: > Hi, > > I have a html string in an object, when I do repr() of that object, I get > value as: > > {'Id' : 1, 'Body': u' Hello '} > > I don't wish to have 'u' as the character in my string representation. As > this is not a valid json notation

Re: simple string format question

2012-10-15 Thread Chris Rebert
On Mon, Oct 15, 2012 at 5:12 AM, Neal Becker wrote: > Is there a way to specify to format I want a floating point written with no > more > than e.g., 2 digits after the decimal? I tried {:.2f}, but then I get all > floats written with 2 digits, even if they are 0: > > 2.35 << yes, that's what I

Re: What's the tidy/elegant way to protect this against null/empty parameters?

2012-10-15 Thread Chris Rebert
On Mon, Oct 15, 2012 at 4:23 AM, wrote: > I want to fix an error in some code I have installed, however I don't > really want to just bodge it. "bodge". Well, I learned a new word this morning! > The function producing the error is:- > > def get_text(self, idx): # override ! >

Re: trouble with nested closures: one of my variables is missing...

2012-10-13 Thread Chris Rebert
On Saturday, October 13, 2012, Cameron Simpson wrote: > I'm having some trouble with closures when defining a decorator. > However, I can't make my make_file_property function work. I've stripped > the code down and it does this: > Traceback (most recent call last): > File "foo.py", li

  1   2   3   4   5   6   7   8   9   10   >