Re: functions, optional parameters

2015-05-09 Thread Steven D'Aprano
On Sun, 10 May 2015 01:35 pm, Rustom Mody wrote: > On Sunday, May 10, 2015 at 8:16:07 AM UTC+5:30, Steven D'Aprano wrote: >> I predict that the majority of the time, late binding would just be a >> pointless waste of time: >> >> def process_string(thestr, start=0, end=None, slice=1, reverse=True)

Re: functions, optional parameters

2015-05-09 Thread Steven D'Aprano
On Sun, 10 May 2015 01:33 pm, Chris Angelico wrote: > On Sun, May 10, 2015 at 12:45 PM, Steven D'Aprano > wrote: >> This is the point where some people try to suggest some sort of >> complicated, fragile, DWIM heuristic where the compiler tries to guess >> whether the user actually wants the defa

Re: functions, optional parameters

2015-05-09 Thread Rustom Mody
On Sunday, May 10, 2015 at 8:16:07 AM UTC+5:30, Steven D'Aprano wrote: > I predict that the majority of the time, late binding would just be a > pointless waste of time: > > def process_string(thestr, start=0, end=None, slice=1, reverse=True): > pass > > Why would you want 0, None, 1 and True

Re: functions, optional parameters

2015-05-09 Thread Chris Angelico
On Sun, May 10, 2015 at 12:45 PM, Steven D'Aprano wrote: > This is the point where some people try to suggest some sort of complicated, > fragile, DWIM heuristic where the compiler tries to guess whether the user > actually wants the default to use early or late binding, based on what the > expres

Re: functions, optional parameters

2015-05-09 Thread Steven D'Aprano
On Sat, 9 May 2015 01:50 am, Michael Welle wrote: [...] >> How about this definition: >> >> default = 23 >> def spam(eggs=default): >> pass >> >> del default >> >> print spam() >> >> >> Do you expect the function call to fail because `default` doesn't exist? > > If I refer

Re: Jython from bathc file?

2015-05-09 Thread Rustom Mody
On Sunday, May 10, 2015 at 7:55:22 AM UTC+5:30, vjp...@at.biostrategist.dot.dot.com wrote: > I have to try this and see if there is ome kind of init file in jython/python > sorta like autoexec.bat. Ialso have no idea if the commands they provide are > all it takes to run the app or I have to stay

Re: Jython from bathc file?

2015-05-09 Thread vjp2 . at
I have to try this and see if there is ome kind of init file in jython/python sorta like autoexec.bat. Ialso have no idea if the commands they provide are all it takes to run the app or I have to stay in jython.. sorry, I'm thinking at loud.. ok, thanks to all..

Re: Jython from bathc file?

2015-05-09 Thread vjp2 . at
Tee from gnuutils?? - = - Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist http://www.panix.com/~vjp2/vasos.htm ---{Nothing herein constitutes advice. Everything fully disclaimed.}--- [Homeland Security mean

Re: getting fieldnames from Dictreader before reading lines

2015-05-09 Thread Vincent Davis
On Sat, May 9, 2015 at 5:55 PM, Dave Angel wrote: > > 1) you're top-posting, putting your response BEFORE the stuff you're responding to. I responded to my own email, seemed ok to top post on myself saying it was resolved. > > 2) both messages are in html, which thoroughly messed up parts of y

Re: getting fieldnames from Dictreader before reading lines

2015-05-09 Thread Dave Angel
On 05/09/2015 07:01 PM, Vincent Davis wrote: Not sure what I was doing wrong, it seems to work now. I still see two significant things wrong: 1) you're top-posting, putting your response BEFORE the stuff you're responding to. 2) both messages are in html, which thoroughly messed up parts

Re: Jython from bathc file?

2015-05-09 Thread Dave Angel
On 05/09/2015 05:04 PM, vjp2...@at.biostrategist.dot.dot.com wrote: Thanks.. I suspected it wasn't meant to be taken as in the file THe one thing I'm not sure if Jython is suppsosedto keep running after the initisl stuff is loaded in.. To put the question in purely DOS terms if you run a progr

Re: getting fieldnames from Dictreader before reading lines

2015-05-09 Thread Vincent Davis
Not sure what I was doing wrong, it seems to work now. Vincent Davis 720-301-3003 On Sat, May 9, 2015 at 4:46 PM, Vincent Davis wrote: > I am reading a file with Dictreader and writing a new file. I want use the > fieldnames in the Dictwriter from the reader. See below How should I be > doing t

Re: getting fieldnames from Dictreader before reading lines

2015-05-09 Thread Mark Lawrence
On 09/05/2015 23:46, Vincent Davis wrote: I am reading a file with Dictreader and writing a new file. I want use the fieldnames in the Dictwriter from the reader. See below How should I be doing this? See how I am using reader.fieldnames in the the Dictwriter. I get an error (below) with open(r

Re: Jython from bathc file?

2015-05-09 Thread Michael Torrie
On 05/09/2015 03:04 PM, vjp2...@at.biostrategist.dot.dot.com wrote: > Thanks.. I suspected it wasn't meant to be taken as in the file > > THe one thing I'm not sure if Jython is suppsosedto keep running > after the initisl stuff is loaded in.. > > > To put the question in purely DOS terms if you

getting fieldnames from Dictreader before reading lines

2015-05-09 Thread Vincent Davis
I am reading a file with Dictreader and writing a new file. I want use the fieldnames in the Dictwriter from the reader. See below How should I be doing this? See how I am using reader.fieldnames in the the Dictwriter. I get an error (below) with open(readfile, 'r', encoding='utf-8', errors='igno

Re: Jython from bathc file?

2015-05-09 Thread vjp2 . at
Thanks.. I suspected it wasn't meant to be taken as in the file THe one thing I'm not sure if Jython is suppsosedto keep running after the initisl stuff is loaded in.. To put the question in purely DOS terms if you run a program can you pipe it some commands and then keep it running to take the

Re: Moving to Python 3.x

2015-05-09 Thread Terry Reedy
On 5/9/2015 2:30 PM, Antranig Vartanian wrote: Hay, I learned the basics of python using the book "Think Python" (http://www.greenteapress.com/thinkpython/) which was good (IMHO), and it teaches in Python 2.7. Now I'm trying to write my first python+gtk program. anyways, my question will be, is

Re: Moving to Python 3.x

2015-05-09 Thread Ian Kelly
On Sat, May 9, 2015 at 12:30 PM, Antranig Vartanian wrote: > Hay, > > I learned the basics of python using the book "Think Python" > (http://www.greenteapress.com/thinkpython/) which was good (IMHO), and it > teaches in Python 2.7. Now I'm trying to write my first python+gtk program. > > anyways,

Re: Moving to Python 3.x

2015-05-09 Thread Jason C. McDonald
On 05/09/2015 11:30 AM, Antranig Vartanian wrote: Hay, I learned the basics of python using the book "Think Python" (http://www.greenteapress.com/thinkpython/) which was good (IMHO), and it teaches in Python 2.7. Now I'm trying to write my first python+gtk program. anyways, my question will be,

Moving to Python 3.x

2015-05-09 Thread Antranig Vartanian
Hay, I learned the basics of python using the book "Think Python" (http://www.greenteapress.com/thinkpython/) which was good (IMHO), and it teaches in Python 2.7. Now I'm trying to write my first python+gtk program. anyways, my question will be, is it so necessary to move to python3.x ASAP?

Re: numpy and cython

2015-05-09 Thread Mark Lawrence
On 09/05/2015 17:09, pauld11718 wrote: An interesting observation : Any simple program with just : cimport numpy as np doesnot compile. Fascinating. What has this got to do with the general election results from the UK? Or is there some other context that you're not prepared to let us i

Re: functions, optional parameters

2015-05-09 Thread Ian Kelly
On Fri, May 8, 2015 at 9:50 AM, Michael Welle wrote: > > Steven D'Aprano writes: >> >> If your language uses late binding, it is very inconvenient to get early >> binding when you want it. But if your language uses early binding, it is >> very simple to get late binding when you want it: just put

Re: numpy and cython

2015-05-09 Thread Mark Lawrence
On 09/05/2015 16:56, pauld11718 wrote: NO the compilation isn't working... The setup.py : from distutils.core import setup from Cython.Build import cythonize setup( ext_modules = cythonize("visco.pyx") ) If you cannot be bothered to supply any context so I've no idea what you're talki

Re: numpy and cython

2015-05-09 Thread pauld11718
An interesting observation : Any simple program with just : cimport numpy as np doesnot compile. -- https://mail.python.org/mailman/listinfo/python-list

Re: numpy and cython

2015-05-09 Thread pauld11718
NO the compilation isn't working... The setup.py : from distutils.core import setup from Cython.Build import cythonize setup( ext_modules = cythonize("visco.pyx") ) -- https://mail.python.org/mailman/listinfo/python-list

Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

2015-05-09 Thread Chris Angelico
On Sun, May 10, 2015 at 1:13 AM, Steven D'Aprano wrote: > FileNotFoundError means that the program did run, it tried to open a file, > but the file doesn't exist. Normally it does, at least. Sometimes it means that a *directory* doesn't exist (for instance, you can get this when you try to create

Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

2015-05-09 Thread Steven D'Aprano
On Sat, 9 May 2015 08:31 pm, zljubisic...@gmail.com wrote: > It works, but if you change title = title[:232] to title = title[:233], > you will get "FileNotFoundError: [Errno 2] No such file or directory". Which is a *completely different* error from SyntaxError: 'unicodeescape' codec can't de

Re: numpy and cython

2015-05-09 Thread Chris Angelico
On Sun, May 10, 2015 at 12:51 AM, pauld11718 wrote: > Unable to compile : > /usr/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using > deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API > NPY_1_7_API_VERSION" [-Wcpp] > #warning "Using deprecated NumPy API,

numpy and cython

2015-05-09 Thread pauld11718
Unable to compile : import numpy as np cimport numpy as np import math as m DTYPE = np.float ctypedef np.float_t DTYPE_t def visc1(float t, float dcal): cdef float h, tr, trinv, rhor cdef float eta0, sumi, i, sumj, im1, jm1, eta cdef np.ndarray vb = np.array([1.0, 0.940695, 0

Re: Seralization

2015-05-09 Thread Cecil Westerhof
Op Saturday 9 May 2015 10:37 CEST schreef Cecil Westerhof: > To make serialization a bit easier I made a few functions to get, > save and convert between the different types. As I see it pickle and > json are probably used the most. I also have a get and save for > marshal. But no conversion to ma

Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

2015-05-09 Thread Dave Angel
On 05/09/2015 06:31 AM, zljubisic...@gmail.com wrote: title = title[:232] title = title.replace(" ", "_").replace("/", "_").replace("!", "_").replace("?", "_")\ .replace('"', "_").replace(':', "_").replace(',', "_").replace('"', '')\ .replace('\n', '_'

Re: calling base class method fetches no results

2015-05-09 Thread david jhon
I am really sorry for any inconvenience caused, I was trying to fix this bug from last 2 days so I had to post it here. It now has been resolved. Thanks a lot for your time. I'll be careful again. Have a great weekend! On Sat, May 9, 2015 at 4:36 PM, Dave Angel wrote: > On 05/09/2015 03:59 AM, d

Re: Seralization

2015-05-09 Thread Cecil Westerhof
Op Saturday 9 May 2015 11:16 CEST schreef Chris Angelico: > On Sat, May 9, 2015 at 6:37 PM, Cecil Westerhof wrote: >> The code: >> def get_json(json_file): >> with open(json_file, 'rb') as in_f: >> return json.load(in_f) >> >> def get_marshal(marshal_file): >> with open(marshal_file, 'rb') as in_

Re: calling base class method fetches no results

2015-05-09 Thread Dave Angel
On 05/09/2015 03:59 AM, david jhon wrote: Hi, I am sorry for sending in five attachments, I cloned the code from here : Let me explain it here: Please don't top-post. Your earlier problem description, which I could make no sense of, is now located af

Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

2015-05-09 Thread zljubisicmob
Steven, please do look at the code bellow: # C:\Users\zoran\PycharmProjects\mm_align\hrt3.cfg contents # [Dir] # ROOTDIR = C:\Users\zoran\hrt import os import shutil import configparser import requests import re Config = configparser.ConfigParser() Config.optionxform = str # preserve case in i

Re: Jython from bathc file?

2015-05-09 Thread Steven D'Aprano
On Sat, 9 May 2015 09:36 am, vjp2...@at.biostrategist.dot.dot.com wrote: > How do I do this in a .bat file? > Do I include the Jython or pipe it? > > % CLASSPATH=$CLASSPATH:$RDBASE/Code/JavaWrappers/gmwrapper/org.RDKit.jar; > jython > -Djava.library.path=$RDBASE/Code/JavaWrappers/gmwrapper > Jyt

Re: Jython from bathc file?

2015-05-09 Thread Todd Vargo
On 5/8/2015 7:36 PM, vjp2...@at.biostrategist.dot.dot.com wrote: How do I do this in a .bat file? Do I include the Jython or pipe it? % CLASSPATH=$CLASSPATH:$RDBASE/Code/JavaWrappers/gmwrapper/org.RDKit.jar; jython -Djava.library.path=$RDBASE/Code/JavaWrappers/gmwrapper Jython 2.2.1 on java1.6

Re: Seralization

2015-05-09 Thread Chris Angelico
On Sat, May 9, 2015 at 6:37 PM, Cecil Westerhof wrote: > The code: > def get_json(json_file): > with open(json_file, 'rb') as in_f: > return json.load(in_f) > > def get_marshal(marshal_file): > with open(marshal_file, 'rb') as in_f: > return marshal.

Re: Is this unpythonic?

2015-05-09 Thread Frank Millman
"Gregory Ewing" wrote in message news:cr5sc6fgfm...@mid.individual.net... > Frank Millman wrote: > > The absolutely clearest way to write it would > probably be > >def f(things = None): > "things is a mapping of stuff to be operated on" > if things: > for key in things:

Re: Useful module to be written by a newbie

2015-05-09 Thread Cecil Westerhof
Op Saturday 9 May 2015 08:10 CEST schreef Michael Welle: > Cecil Westerhof writes: > >> Op Wednesday 29 Apr 2015 21:03 CEST schreef Peter Otten: >> > Realistically a Python coder with a little experience will have > a glance at your code and run away. Oops, that is not nice to h

Seralization

2015-05-09 Thread Cecil Westerhof
To make serialization a bit easier I made a few functions to get, save and convert between the different types. As I see it pickle and json are probably used the most. I also have a get and save for marshal. But no conversion to marshal, because in principle you should not use it, so a conversion t

Re: calling base class method fetches no results

2015-05-09 Thread Mark Lawrence
On 09/05/2015 08:59, david jhon wrote: Hi, I am sorry for sending in five attachments, I cloned the code from here : Let me explain it here: [nearly 300 lines of code snipped] I am really sorry for any inconvenience caused. I, ve tried to make it a b

Re: calling base class method fetches no results

2015-05-09 Thread david jhon
Hi, I am sorry for sending in five attachments, I cloned the code from here : Let me explain it here: Routing Base class defined in DCRouting.py: import logging from copy import copy class Routing(object): '''Base class for data center network routin

Re: Is this unpythonic?

2015-05-09 Thread Gregory Ewing
Frank Millman wrote: There are two operations I might perform on the dictionary - 1. iterate over the keys and retrieve the values 2: use 'in' to test if a given string exists as a key Both of these operations will work on a tuple and give the desired result, so it is a very valid workaround.

Re: functions, optional parameters

2015-05-09 Thread Gregory Ewing
Chris Angelico wrote: So no, it isn't proof - it's equally well explained by the code object being constant. I suppose, strictly speaking, that's true -- but then the code object *might as well* be created at compile time, since the semantics are identical. In any case, it's easy to see from

Re: calling base class method fetches no results

2015-05-09 Thread Mark Lawrence
On 09/05/2015 07:41, david jhon wrote: Hello everyone, I am new to python and trying to run an example code from mininet tests. Basically, I am trying to call a method in Hcontroller.py from base class Routing defined in DCRouting.py which runs and fetches all the required results in install_rea

Re: SSL Socket Error

2015-05-09 Thread Kev Dwyer
shdwkee...@gmail.com wrote: > Ive setup a Debian server with Python 2.7.9. Have everything running and > SSL as well, but when I try and login to using HTTPS:// I get this error: > > Incoming web connection from ('192.168.15.177', 53202) > error: uncaptured python exception, closing channel lis