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: 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: 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: 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-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: 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: 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: 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: 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: 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: How to print a number as if in the python interpreter?

2012-07-06 Thread Chris Rebert
On Fri, Jul 6, 2012 at 3:38 PM, Peng Yu wrote: > Hi, > > In [2]: sum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1]) > Out[2]: 0. > > In ipython, I got the above output. But I got a different output from > "print". Is there a way to print exact what I saw in ipython? > > ~/linux/test/pyt

Re: something go wrongly

2012-07-07 Thread Chris Rebert
On Sat, Jul 7, 2012 at 10:23 AM, levi nie wrote: > my code: > > aList=[1,2,3,4,5,6,7,8,9,10] > xList=[1,2,3] > print "now aList is",aList.extend(xList) > > output: > now aList is None > > what i want is [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3] See http://stackoverflow.com/a/1682601 list.extend(),

Re: help needed with subprocess, pipes and parameters

2012-07-14 Thread Chris Rebert
On Friday, July 13, 2012, nuffi wrote: > > If I copy and paste the following command into a command window, it does > what I need. > > c:\Programs\bob\bob.exe -x -y "C:\text\path\to some\file.txt" | > c:\Programs\kate\kate.exe -A 2 --dc "Print Media Is Dead" --da "Author" > --dt "Title" --hf "Ti

Re: Diagramming code

2012-07-15 Thread Chris Rebert
On Sun, Jul 15, 2012 at 6:26 PM, hamilton wrote: > Subject: Diagramming code > > Is there any software to help understand python code ? What sort of diagrams? Control flow diagrams? Class diagrams? Sequence diagrams? Module dependency diagrams? There are many different types you could be referrin

Re: Diagramming code

2012-07-15 Thread Chris Rebert
On Sun, Jul 15, 2012 at 6:57 PM, hamilton wrote: > On 7/15/2012 7:38 PM, Chris Rebert wrote: >> >> On Sun, Jul 15, 2012 at 6:26 PM, hamilton wrote: >>> >>> Subject: Diagramming code >>> >>> Is there any software to help understand python code ?

Re: ssl: add msg_callback

2012-07-25 Thread Chris Rebert
On Wed, Jul 25, 2012 at 8:47 PM, Thiébaud Weksteen wrote: > > Hi python-list, > > I wrote a patch for Python 3.2.3 to expose the function > SSL_CTX_set_msg_callback in the module _ssl. > > I was actually surprise this function was not already in the > standard library as it is really handy: Well,

Re: keyerror '__repr__'

2012-08-04 Thread Chris Rebert
On Sat, Aug 4, 2012 at 7:48 AM, vijay shanker wrote: > hi > i have this class book > > class book: > def __init__(self,name,price): > self.name = name > self.price = price > > def __getattr__(self,attr): > if attr == '__str__': > print 'intercepting in-b

Re: Arithmetic with Boolean values

2012-08-11 Thread Chris Rebert
On Sat, Aug 11, 2012 at 3:30 PM, John Ladasky wrote: > for x in range(1 + not(len(L) % 2)): > # Do stuff > > This provoked a SyntaxError. I investigated this further with my interpreter > (ipython). > In [5]: not(1) > Out[5]: False > > In [6]: not(len(L) % 2) > Out[6]: False > > In [7]: 1

Re: it's really strange.how does it work?

2012-08-14 Thread Chris Rebert
On Tue, Aug 14, 2012 at 10:07 PM, levi nie wrote: > ok,what does "start, stop = 0, start" in the code mean? > it's really strange.how does it work? It's just parallel assignment (http://en.wikipedia.org/wiki/Assignment_%28computer_science%29#Parallel_assignment ). As to exactly how it works: htt

Re: newbie ``print`` question

2012-09-02 Thread Chris Rebert
On Sun, Sep 2, 2012 at 10:23 AM, gwhite wrote: > I can't figure out how to stop the "add a space at the beginning" > behavior of the print function. > print 1,;print 2, > 1 2 > > See the space in between the 1 and the 2 at the output print to the > command console? > > The help for print is:

Re: newbie ``print`` question

2012-09-02 Thread Chris Rebert
On Sun, Sep 2, 2012 at 1:24 PM, Mark Lawrence wrote: > On 02/09/2012 20:58, me wrote: >> >> Well you can convert the ints to str then concatenate them. >> >> print "1" + "2" >> > > Please post other parts of the thread so people can get the context or don't > bother posting at all, thanks. Please

Re: get the matched regular expression position in string.

2012-09-03 Thread Chris Rebert
On Mon, Sep 3, 2012 at 1:18 AM, contro opinion wrote: > Subject: get the matched regular expression position in string. As is often the case in Python, string methods suffice. Particularly for something so simple, regexes aren't necessary. > Here is a string : > > str1="ha,hihi,a,ok" > > I w

Re: subprocess call is not waiting.

2012-09-13 Thread Chris Rebert
On Thu, Sep 13, 2012 at 11:36 AM, wrote: > Thanks, guys. > MRAB-RedHat 6 64-bit, Python 2.6.5 In your Unix shell, what does the command: type htar output? > JM-Here's the relevant stuff from my last try. If you could give a complete, self-contained example, it would assist us in troublesho

Re: subprocess call is not waiting.

2012-09-13 Thread Chris Rebert
On Thu, Sep 13, 2012 at 8:17 AM, wrote: > I have a subprocess.call > But it doesn't work as intended. > Should I just go back to os.system? Did the os.system() version work? As of recent Python versions, os.system() is itself implemented using the `subprocess` module, so if it does work, then

Re: subprocess call is not waiting.

2012-09-14 Thread Chris Rebert
On Fri, Sep 14, 2012 at 5:22 AM, wrote: > os.system worked fine, and I found something in another section of code that > was causing the "Too many open errors." (I was fooled, because output from > subprocess call didn't seem to be coming out until the open files error. > > I'll go back and pla

Re: datetime issue

2012-09-15 Thread Chris Rebert
On Sat, Sep 15, 2012 at 10:33 AM, Νικόλαος Κούρας wrote: > Hello again, > > one small matter too. > > # get some enviromental values > locale.setlocale(locale.LC_ALL, 'el_GR') > date = datetime.datetime.now().strftime( '%y-%m-%d %H:%M:%S' ) > > although iam setting greek as locale Locales don't

Re: 'indent'ing Python in windows bat

2012-09-17 Thread Chris Rebert
On Mon, Sep 17, 2012 at 8:28 PM, Dennis Lee Bieber wrote: > On Mon, 17 Sep 2012 21:08:32 -0400, David Smith > declaimed the following in gmane.comp.python.general: > >> >> How do I "indent" if I have something like: >> if (sR=='Cope'): sys.exit(1) elif (sR=='Perform') sys.exit(2) else >> sys.exit

Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine (using ssh ?)

2012-09-20 Thread Chris Rebert
On Wed, Sep 19, 2012 at 12:50 PM, ashish wrote: > 2. I have a python script, local.py, running on 'local' which needs to pass > arguments ( 3/4 string arguments, containing whitespaces like spaces, etc ) > to a python script, remote.py running on 'remote' (the remote machine). > 3. Has anybody

Re: python idioms : some are confusing

2012-09-20 Thread Chris Rebert
On Thu, Sep 20, 2012 at 10:34 PM, Vineet wrote: > Amongst the python idioms, how the below-mentioned make sense? These aren't idioms (that term has a specific technical meaning in programming); they're *way* too abstract to be idioms. "Design principles" or "design guidelines" would be a better d

Re: Functional way to compare things inside a list

2012-09-21 Thread Chris Rebert
On Fri, Sep 21, 2012 at 1:23 AM, Chris Angelico wrote: > On Fri, Sep 21, 2012 at 8:58 AM, wrote: > That gets the result, but probably not in the cleanest way. I'm not > sure off-hand if Python has a convenient way to curry a function, http://docs.python.org/library/functools.html#functools.par

Re: Functional way to compare things inside a list

2012-09-21 Thread Chris Rebert
On Thu, Sep 20, 2012 at 3:58 PM, wrote: > Hi, > > list = [{'1': []}, {'2': []}, {'3': ['4', '5']}] Are the dictionaries each guaranteed to only contain a single key-value pair? (Or is your example just simplistic?) > I want to check for a value (e.g. '4'), and get the key of the dictionary > th

Re: For Counter Variable

2012-09-25 Thread Chris Rebert
On Tue, Sep 25, 2012 at 2:46 AM, Mark Lawrence wrote: > On 25/09/2012 10:32, [email protected] wrote: >> >> I wrote my first program on a PDP-8. I discovered Python >> at release 1.5.? >> >> Now years later... I find Python more and more unusable. >> I'm toying more and more with the go languag

Re: How to pass FILE *

2012-09-28 Thread Chris Rebert
On Fri, Sep 28, 2012 at 2:55 PM, xDog Walker wrote: > > The function I am trying to call wants a FILE *: > > dlg_progressbox(const char *title, > const char *cprompt, > int height, > int width, > int pauseopt, > FILE *

Re: Why is pylaucher in Python 3.3 being installed in Windows folder?

2012-10-03 Thread Chris Rebert
On Wed, Oct 3, 2012 at 8:21 PM, Ian Kelly wrote: > On Wed, Oct 3, 2012 at 8:04 PM, Steven D'Aprano > wrote: >> On Wed, 03 Oct 2012 14:13:10 -0700, Piotr Dobrogost wrote: >> >>> Why is pylauncher in Python 3.3 being installed in Windows folder and >>> not in Program Files folder? Installing into W

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

2012-10-03 Thread Chris Rebert
On Wed, Oct 3, 2012 at 11:31 AM, Wolfgang Keller wrote: >> I'm really new to Usenet/Newsgroups, but... I'd like to learn some >> new programming language, because I learnt a bit of Perl though its >> OOP is ugly. So, after searching a bit, I found Python and Ruby, and >> both of they are cute. So,

Re: Unpaking Tuple

2012-10-06 Thread Chris Rebert
On Sat, Oct 6, 2012 at 3:09 AM, sajuptpm wrote: > Hi, > > I am using python 2.6. > > I need a way to make following code working without any ValueError . a, b, c, d = (1,2,3,4) a, b, c, d = (1,2,3). > > Note: Number of values in the tuple will change dynamically. Then you arguably want

Re: question on log as an instance method

2012-10-07 Thread Chris Rebert
On Sun, Oct 7, 2012 at 1:33 AM, Franck Ditter wrote: > Hi ! Here is Python 3.2.3, MacOSX-Lion > > Question 0 : I may consider + as an hidden instance method , as > 1+2 is equivalent to (1).__add__(2) ? No, it's not nearly that simple. It's technically equivalent to operator.add(1, 2) [ http://doc

Re: getting the state of an object

2012-10-07 Thread Chris Rebert
On Sun, Oct 7, 2012 at 1:50 AM, Franck Ditter wrote: > Hi ! > > Another question. When writing a class, I have often to > destructure the state of an object as in : > > def foo(self) : > (a,b,c,d) = (self.a,self.b,self.c,self.d) > ... big code with a,b,c,d ... I would generally strongly f

Re: question on log as an instance method

2012-10-07 Thread Chris Rebert
On Sun, Oct 7, 2012 at 1:33 AM, Franck Ditter wrote: > As a matter of netiquette, please don't post from a plausible-but-invalid email address, especially at a domain that doesn't seem to belong to you. (I got a mailer-daemon bounce when replying to your posts.) If you must use an invalid address

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

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: > [email protected] 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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-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: 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: 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: os.path.realpath(path) bug on win7 ?

2013-01-05 Thread Chris Rebert
On Sat, Jan 5, 2013 at 10:55 PM, iMath <[email protected]> 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: 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: 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: 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: 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: 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: 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: 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

python.org mailman web interface problem

2012-01-23 Thread Chris Rebert
Accessing http://mail.python.org/mailman/listinfo/ currently gives: """ Bug in Mailman version 2.1.12 We're sorry, we hit a bug! Please inform the webmaster for this site of this problem. Printing of traceback and other system information has been explicitly inhibited, but the webmaster can find

Re: String interning in Python 3 - missing or moved?

2012-01-23 Thread Chris Rebert
On Mon, Jan 23, 2012 at 4:38 PM, Chris Angelico wrote: > Python 2 can intern 'str' (bytes) strings (with the eponymous builtin, > and with C API functions), though not unicode. Python 3 does not have > that builtin, nor the C API; I can't find any support for either str > or bytes. > > Has it been

Re: String interning in Python 3 - missing or moved?

2012-01-24 Thread Chris Rebert
On Tue, Jan 24, 2012 at 12:17 AM, Stefan Behnel wrote: > Chris Angelico, 24.01.2012 05:47: >> Lua and Pike both quite happily solved hash collision attacks in their >> interning of strings by randomizing the hash used, because there's no >> way to rely on it. Presumably (based on the intern() docs

Re: How to work around a unicode problem?

2012-01-24 Thread Chris Rebert
On Tue, Jan 24, 2012 at 3:57 AM, wrote: > I have a small python program that uses the pyexiv2 package to view > exif data in image files. > > I've hit a problem because I have a filename with accented characters > in its path and the pyexiv2 code traps as follows:- > >    Traceback (most recent c

Re: search google with python

2012-01-25 Thread Chris Rebert
On Wed, Jan 25, 2012 at 1:55 AM, Tracubik wrote: > Hi all, > i'ld like to make a simple program for searching images from python. > All it have to do is make a search in google images and return the link > of the images (20 images is enough i think) > > Is there any API or modules i can use? http

Re: Find the mime type of a file.

2012-01-25 Thread Chris Rebert
On Wed, Jan 25, 2012 at 9:04 AM, Olive wrote: > I want to have a list of all the images in a directory. To do so I want > to have a function that find the mime type of a file. I have found > mimetypes.guess_type but it only works by examining the extension. In > GNU/Linux the "file" utility do muc

Re: Current Web URL

2012-01-25 Thread Chris Rebert
On Wed, Jan 25, 2012 at 11:38 AM, William Abdo wrote: > Hi All, > > I have been breaking my brains to find a solution to determining what the > current URL is in a web browser navigation bar. > > It cannot be a prefixed values since I will not know what platform it is > running from at the time it

Re: PyPI - how do you pronounce it?

2012-01-28 Thread Chris Rebert
On Fri, Jan 27, 2012 at 11:48 PM, Chris Angelico wrote: > Hopefully this will be a step up from Rick's threads in usefulness, > but I'm aware it's not of particularly great value! > > How do you pronounce PyPI? Is it: > * Pie-Pie? Personally, yes. Reflecting upon it, I now recognize this is ambig

Re: Questions regarding the daemon module.

2012-01-28 Thread Chris Rebert
On Sat, Jan 28, 2012 at 5:54 AM, David Lambert wrote: > I was looking for a simple way to daemonize a Python process, and found: > > http://www.python.org/dev/peps/pep-3143/ > > I used easy_install to add this package (I thought), but when I attempted to > use the example in the above link, I got

Re: Reading Adobe PDF File

2012-01-28 Thread Chris Rebert
On Sat, Jan 28, 2012 at 9:52 PM, Shrewd Investor wrote: > Hi, > > I have a very large Adobe PDF file.  I was hoping to use a script to > extract the information for it.  Is there a way to loop through a PDF > file using Python? Haven't used it myself, but: http://www.unixuser.org/~euske/python/pd

Re: Does python(django) have an official database driver to access SQLFire

2012-01-29 Thread Chris Rebert
On Sat, Jan 28, 2012 at 11:12 PM, Niu.Jack wrote: > I have a question on Python.  Does python(django) have an official database > driver to access SQLFire? Or is there any roadmap to deliver an official > database driver? Sounds like no; SQLFire's FAQ (http://communities.vmware.com/docs/DOC-16640

Re: autoconf error on Windows

2012-01-29 Thread Chris Rebert
On Sun, Jan 29, 2012 at 12:52 AM, Alec Taylor wrote: > PyCrypto's install is giving an autoconf error on Windows, whether I > install from the git repo or normally. > > Traceback (most recent call last): >  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command >    cmd_obj.run() > >  

  1   2   3   4   5   6   7   8   9   10   >