Re: Convert a scientific notation to decimal number, and still keeping the data format as float64

2019-10-21 Thread Piet van Oostrum
Piet van Oostrum writes: > doganad...@gmail.com writes: > >> I dont know much about scala actually. I have just have tried to give >> 0.0001 and it returned a presentation with an 'e' .whereas python takes >> 0.0001 and gives 0.0001 . it made me think python is

Re: Convert a scientific notation to decimal number, and still keeping the data format as float64

2019-10-21 Thread Piet van Oostrum
doganad...@gmail.com writes: > I dont know much about scala actually. I have just have tried to give > 0.0001 and it returned a presentation with an 'e' .whereas python takes > 0.0001 and gives 0.0001 . it made me think python is better in that > specific subject. > > However, python though starts

Re: Convert a scientific notation to decimal number, and still keeping the data format as float64

2019-10-20 Thread Piet van Oostrum
doganad...@gmail.com writes: > > In the meanwhile I have checked Scala , and it's more limited then Python. > As an example: > 0.0001 > 1.0E-4: Double > Why do you think this means Scala is more limited than Python? -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP

Re: Jupyter Notebook -> PDF with A4 pages?

2019-10-16 Thread Piet van Oostrum
Martin Schöön writes: > Den 2019-10-15 skrev Piet van Oostrum : >> >> What does this report? Compare if there is a difference between home and >> work. >> >> from jupyter_core.paths import jupyter_path >> print(jupyter_path('notebook','

Re: Instantiating sub-class from super

2019-10-16 Thread Piet van Oostrum
n making hasty subdivisions. In this context that means attributes (that can be None) rather than subclasses. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Hello, I need help.

2019-10-15 Thread Piet van Oostrum
hat is called IDLE. It is simpler than Pycharm, but it can do the job. So you can try that. If that also gives an error you could try to reinstall Python. If you are familiar with the command line, then that is also a possibility. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8D

Re: Jupyter Notebook -> PDF with A4 pages?

2019-10-15 Thread Piet van Oostrum
Martin Schöön writes: > Den 2019-10-13 skrev Piet van Oostrum : >> Martin Schöön writes: >> >>> Is there a way to do "Download as PDF" and get A4 pages instead >>> of Letter? Yes, I know I can do "Download as LaTeX" and edit the >> >

Re: Jupyter Notebook -> PDF with A4 pages?

2019-10-13 Thread Piet van Oostrum
you prefer that. You can leave out the c.LatexExporter.template_file line if you don't want the LaTeX exporter to generate A4. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Strange tab completion oddity with enums?

2019-10-07 Thread Piet van Oostrum
at's going on? >>> Foo.__abstractmethods__ Traceback (most recent call last): File "", line 1, in AttributeError: __abstractmethods__ -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Print to Paper

2019-10-04 Thread Piet van Oostrum
d probably want to generate a PDF file and send that to the printer, possibly with the use of LaTeX. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: itertools query

2019-09-27 Thread Piet van Oostrum
about (5,7), (5,8) and (6,8)? -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: CSV reader ignore brackets

2019-09-26 Thread Piet van Oostrum
here is some working code: def PReader(csvfile): import re for line in csvfile: line = re.sub(r'\(.*?\)', '"\g<0>"', line) yield line import csv with open('testcsv.csv') as csvfile: reader = csv.reader(PReader(csvfile), quot

Re: Most efficient way to replace ", " with "." in a array and/or dataframe

2019-09-23 Thread Piet van Oostrum
; I found that it also works without the letter b. > I added the b because the default in the definition of read_csv is b'.', but you are right, it works with just ','. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Most efficient way to replace ", " with "." in a array and/or dataframe

2019-09-22 Thread Piet van Oostrum
cation in dataframe before extracting the numeric fields to the > array. > > Please, any comments or tip? data = pd.read_csv ('table.csv', sep = ',', skiprows = 1, decimal=b',', skipinitialspace=True) -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: python is bugging

2019-09-21 Thread Piet van Oostrum
code the error is on line 15 1) What is line 15? 2) Always copy/paste the complete error message with your question. 3) Your with body is not indented: with fits.open(fits_filename) as data: df=pd.DataFrame(data[1].data) df.columns=[c.lower() for c in df.columns] print(&

Re: python is bugging

2019-09-21 Thread Piet van Oostrum
acility. When a compound statement is entered interactively, it must be followed by a blank line to indicate completion (since the parser cannot guess when you have typed the last line). Note that each line within a basic block must be indented by the same amount. -- Piet van Oostrum WWW: http://piet

Re: not working

2019-09-17 Thread Piet van Oostrum
gt; |>>> re.search( pattern, '1234' ).group( 1 ) > |IndexError: no such group > |>>> re.search( pattern2, '1234' ).group( 1 ) > |>>> > The second pattern has parentheses, hence a group. The first doesn't. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: pandas loc on str lower for column comparison

2019-09-10 Thread Piet van Oostrum
gt; Confused > > Sayth df1['Difference'] = df1['Current Team'].str.lower().str.strip() == df1['New Team'].str.lower().str.strip() works on whole columns, not only on an individual row. xls = pd.ExcelFile("Melbourne.xlsx") df = xls.par

Re: phyton

2019-09-10 Thread Piet van Oostrum
print(add_vat(101, 'low')) > > Outcome: > > 122.21 > 110.09 > > Thanks! You could use a dictionary to connect the words to the values. As this is homework you have to do it yourself. Learn about dictionaries. Otherwise just use 'if'. -- Piet van

Re: numpy array - convert hex to int

2019-09-10 Thread Piet van Oostrum
') > 27 > ---> 28 my_data_3 = int(my_data_2) > 29 > 30 my_data_4 = my_data_3.astype(np.float) > TypeError: only length-1 arrays can be converted to Python scalars > # >>> my_data_2 = numpy.array(['0a&#

Re: issue in handling CSV data

2019-09-10 Thread Piet van Oostrum
actually treated this as a CSV file. 2) As I said above, if you choose ',' as separator, these will disappear. Similarly, if you choose TAB as seperator, the TABs will disappear. As the format is a strange mixture of the two, you can use either one. But if it would be read with a real

Re: pandas loc on str lower for column comparison

2019-09-05 Thread Piet van Oostrum
Piet van Oostrum writes: > That would select ROWS 0,1,5,6,7, not columns. > To select columns 0,1,5,6,7, use two-dimensional indexes > > df1 = df.iloc[:, [0,1,5,6,7]] > > : selects all rows. And that also solves your original problem. This statement: df1['Difference&#x

Re: pandas loc on str lower for column comparison

2019-09-05 Thread Piet van Oostrum
grab all columns 13 when I requested 5. > UID Name FTE Agent ID Current Leader New Leader Current Team New > Team Current Site New Site Unnamed: 10 Unnamed: 11 Unnamed: 12 > > How do I misunderstand iloc? > That would select ROWS 0,1,5,6,7, not columns. To select columns 0,1,5,6

Re: IDLE missing !

2019-09-01 Thread Piet van Oostrum
I couldn’d find the IDLE shell > with them. Well, on MacOS 10.13.6 (High Sierra) tensorflow 1.14.0 does install on Python 3.7.4, and it also runs. It does give some warnings about deprecations, however. There is also a version 2.0RC which installs and runs without warnings. -- Piet van

Re: ``if var'' and ``if var is not None''

2019-09-01 Thread Piet van Oostrum
;) False In [3]: if var is not None: ...: print('True') ...: else: ...: print('False') True -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: pandas loc on str lower for column comparison

2019-08-31 Thread Piet van Oostrum
at 'Current Team' is spelled differently in the assignment than in the construction of df1? For example a difference in spaces, like a triling space or a breaking vs. non-breaking space? Please check that both are exactly the same. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/

Re: open, close

2019-08-31 Thread Piet van Oostrum
t there is no guarantee. It depends on garbage collection. In your case the file will not be closed as long as there is still a reference to it (as in f). When f disappears and all copies of it as well, the file COULD be closed similarly. On the other hand, the with statement guarantees that

Re: pandas loc on str lower for column comparison

2019-08-30 Thread Piet van Oostrum
oc['New Team'].str.lower().str.strip() > > But on both occasions I receive this error. > > # KeyError: 'the label [Current Team] is not in the [index]' > > if I test df1 before trying to create the new column it works just fine. > > Sayth What

Re: pandas loc on str lower for column comparison

2019-08-29 Thread Piet van Oostrum
Piet van Oostrum writes: > So the correct way to do this is to make df1 a copy rather than a view. > > df1 = df.loc[:, ('UID','Name','New Leader','Current Team', 'New Team')] Or maybe even make an explicit copy: df1 = df[['UID&#

Re: pandas loc on str lower for column comparison

2019-08-29 Thread Piet van Oostrum
27;New Team')] And than it should work. Except that the str.replace is wrong for what you want. It just replaces the literal string "s/+" with an empty string instead of white space. This was wrong in the stackoverflow post. To replace whitespace it should be str.replace(

Re: Why is augmented assignment of a tuple with iterable unpacking invalid syntax?

2019-05-19 Thread Piet van Oostrum
the y is basically part of an expression. But starred expressions are not allowed in expressions, except within explicit parentheses. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Import module from a different subdirectory

2019-05-18 Thread Piet van Oostrum
hat model.py wasn't found in classes, i.e. it was the same error as Peter got. So to get this working you must make sure 'classes' is inside a directory that is in sys.path, for example by adding: sys.path.insert(0, '..') -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Testing the data type of a value

2019-05-12 Thread Piet van Oostrum
t(int) The value of int is the class int, which is the class of 5, so type(5) is also that same class int. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: WebScrapping

2019-02-19 Thread Piet van Oostrum
ainer.find('div', attrs={'class':'item-branding'}) > price = container.find('div', attrs={'class':'item-action'}) > records.append((brand, price)) > When I put this in a python file, and run it under python3.7, it work

Re: Convert a list with wrong encoding to utf8

2019-02-15 Thread Piet van Oostrum
o to get the names?! python3 >>> x = '\xce\x86\xce\xba\xce\xb7\xcf\x82 >>> \xce\xa4\xcf\x83\xce\xb9\xce\xac\xce\xbc\xce\xb7\xcf\x82' >>> b = bytes(ord(c) for c in x) >>> b.decode('utf-8') 'Άκης Τσιάμης' >>> -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: The slash "/" as used in the documentation

2019-02-09 Thread Piet van Oostrum
ce. > > Christian Even simpler: >>> help(len) help(len) Help on built-in function len in module builtins: len(obj, /) Return the number of items in a container. both in python 3.6 and 3.7. This is weird. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: The slash "/" as used in the documentation

2019-02-09 Thread Piet van Oostrum
; f( x; y ) > > (the actual call still would use a comma there). > What are you talking about? What documentation? It seems to me you are talking about a completely different programming language, not python. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Python read text file columnwise

2019-01-11 Thread Piet van Oostrum
('testcsv.csv', newline='') as csvfile: reader = csv.reader(csvfile, delimiter='\t') for row in reader: for i in range(2, 5): row[i] = float(row[i]) print(row) You could convert the first two columns to datetime format if you wish. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Facing an Error after migrating from python 3.4.1 to python 3.6.6 ( Failed to import the site module )

2018-12-28 Thread Piet van Oostrum
` > After migrating from python 3.4.1 to python 3.6.6 > while Executing my project, I'm facing this issue and not able to > resolve it. Can i get any solution for this issue? Could it be that your PYTHONPATH environment variable is set to a directory i

Re: Problem with subprocess.Popen and EINTR

2017-10-29 Thread Piet van Oostrum
Or I could first try to switch to Python 3, as Chris suggested, to see if that makes the problem disappear. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Problem with subprocess.Popen and EINTR

2017-10-28 Thread Piet van Oostrum
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 121, in _eintr_retry_call return func(*args) OSError: [Errno 22] Invalid argument TASK is a string with the name of the shell script. Can anybody shed some light on this? -- Pie

Re: String to Dictionary conversion in python

2017-09-16 Thread Piet van Oostrum
Exception as e: print "%s: %s" % (type(e).__name__, ', '.join(e.args)) >>> literal("'x':1") {'x': 1} >>> literal("x:1") ValueError: malformed string But in non-interactive use you probably want to propagate the exception. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: What extended ASCII character set uses 0x9D?

2017-08-18 Thread Piet van Oostrum
h tape. > By backstepping and punching a DEL over the previous ASCII character you > can "rub out" the character. > Sure, I have done that many times. Years ago. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: how to group by function if one of the group has relationship with another one in the group?

2017-08-01 Thread Piet van Oostrum
Ho Yeung Lee writes: > which function should be used for this problem? > I think it is a kind if clustering, or a connectivity problem. There are special algorithms for that, not just a simple function. Maybe scikit-learn has a suitable algorithm for it. -- Piet van Oostrum WWW

Re: how to sort a list of tuples with custom function

2017-08-01 Thread Piet van Oostrum
t in such a way thet points that are close together in the two-dimensional sense will also be close together in the one-dimensional list. But that is impossible. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Need help to understand not the answer

2017-07-29 Thread Piet van Oostrum
ost recent call last): > File "submission.py", line 61, in __init__ > self.cloc=Location(center_loc) > TypeError: __init__() missing 1 required positional argument: 'y' Location must be called with 2 parameters: a x and a y coordinate, not with another location a

Re: how to group by function if one of the group has relationship with another one in the group?

2017-07-29 Thread Piet van Oostrum
,6),(4,6)] > > for key, group in groupby(items, key=PairKey(isneighborlocation)): > print key, list(group) > > $ python sequential_group_class.py > False [(1, 1)] > True [(2, 3), (2, 4)] > False [(3, 5), (3, 6), (4, 6)] That only works if (a) The elements in the list

Re: Python BeautifulSoup extract html table cells that contains images and text

2017-07-29 Thread Piet van Oostrum
'} > raw_html = requests.get(url, headers=headers) > > raw_data = raw_html.text > soup_data = BeautifulSoup(raw_data, "lxml") > > td = soup_data.findAll('tr')[1:] > > country = [] > > for data in td: > col = data.find_all('td') >

Re: Temporary variables in list comprehensions

2017-04-11 Thread Piet van Oostrum
Vincent Vande Vyvre writes: > final = [(x, y+1) for x, y in zip(e, e)] final = [(x, x+1) for x in e] -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Temporary variables in list comprehensions

2017-04-06 Thread Piet van Oostrum
'. It would be nice if python had a real 'let' construction. Or for example: [(tmp, tmp + 1) for x in data with tmp = expensive_calculation(x)] Alas! -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Getting stdout and stderr from subprocess in correct order

2017-03-04 Thread Piet van Oostrum
call after each print statement, like sys.stdout.flush() Then you get them in order. $ python3 subprc.py a b c d Of course you won't be able to tell from which stream each line comes. The streams are byte streams, not message streams. You would have to put extra information, e.g. a prefix, in your print statements. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Expression can be simplified on list

2016-09-17 Thread Piet van Oostrum
n be simplified to just: if errors: This is quite usual in Python, but some people prefer the more elaborate form, or something like: if len(errors) == 0: -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Something wrong with the PIP, lots of friend have the same problem

2016-08-25 Thread Piet van Oostrum
. What command did you use and what was the result? [Maybe you tried to include images in your post/mail but they did not come through. Just copy/paste the text.] -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Calling a function is faster than not calling it?

2015-06-22 Thread Piet van Oostrum
e("0", 'string', "eval") t1 = Timer("eval(dummy); func()", setup="from __main__ import dummy, func") t2 = Timer("0; eval(code)", setup="from __main__ import code") And then you'll see that t1 is slightly slower than t2. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: singleton ... again

2014-02-13 Thread Piet van Oostrum
t of it; but > we already have it built in :-) There is a use case for a singleton class: when creating the singleton object takes considerable resources and you don't need it always in your program. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: ANN: A new version (0.3.6) of python-gnupg has been released.

2014-02-06 Thread Piet van Oostrum
Vinay Sajip writes: > A new version of the Python module which wraps GnuPG has been > released. > There seem to be 2 gnupg modules for Python. The other one has version number 1.2.5. Very confusing! -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4]

Re: Highlighting program variables instead of keywords?

2014-01-29 Thread Piet van Oostrum
der.com > I seriously think jmf has a mental disorder. So these reactions won't do anything useful. Just ignore. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Can post a code but afraid of plagiarism

2014-01-24 Thread Piet van Oostrum
xtract an element of a list use indexing, like mylist[0]. If you don't know these things or can't find this out yourself, you have a serious lack of knowledge about Python, or maybe about programming, and it is time to learn that first. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Early retirement project?

2014-01-22 Thread Piet van Oostrum
wxjmfa...@gmail.com writes: > In fact, Python just becomes the last tool I (would) > recommend, especially for non-ascii users. > > jmf In fact, Python 3 is one of the best programming tools for non-ASCII users. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE

Re: How to write this as a list comprehension?

2014-01-20 Thread Piet van Oostrum
of a sequence/iterator. There is no way to bind the name(s) to a single object other than putting that object in a one element sequence. I was just looking for a way to avoid that. Functional programming languages have a way to do this with the 'let' or 'where' construction

Re: How to write this as a list comprehension?

2014-01-19 Thread Piet van Oostrum
where (sic!) the last part means as much as where _, mn, dy, _, _, _, wd, _, _ = localtime(then) I find the list comprehension preferable because it makes it more clear that a new list is constructed from an existing list, something that is not as immediately clear with the append construction.

Re: How to write this as a list comprehension?

2014-01-18 Thread Piet van Oostrum
Alain Ketterlin writes: > Piet van Oostrum writes: > [...] >> Python misses a 'where' or 'let'-like construction as in Haskell. > > "let x = v in e" really is (lambda x:e)(v) > You are right, but it is a lot less readable IMHO. -- Piet v

Re: How to write this as a list comprehension?

2014-01-18 Thread Piet van Oostrum
Rustom Mody writes: > On Saturday, January 18, 2014 4:49:55 AM UTC+5:30, Piet van Oostrum wrote: [...] > >> Python misses a 'where' or 'let'-like construction as in Haskell. > > +1 > Yes Ive often been bitten by the lack of a 'comprehension-let

How to write this as a list comprehension?

2014-01-17 Thread Piet van Oostrum
_, mn, dy, _, _, _, wd, _, _ in [localtime(then)]] Python misses a 'where' or 'let'-like construction as in Haskell. Anybody has a more elegant solution? -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.x adoption

2014-01-16 Thread Piet van Oostrum
Travis Griggs writes: > Personally, I wish they’d start python4, sure would take the heat out of > the 3 vs 2 debates. And maybe there’d be a program called twentyfour as > a result. twelve would be sufficient, I would think. -- Piet van Oostrum WWW: http://pietvanoostrum.com

Re: setup.py issue - some files are included as intended, but one is not

2014-01-15 Thread Piet van Oostrum
t. m4_treap.m4 contains this instruction twice: ifdef(/*pyx*/,cp)if current is None: ifdef(/*pyx*/,cp)raise KeyError Which when generating pyx_treap.pyx (with *pyx* defined) expands to the syntactically incorrect cpif current is None: cpraise KeyError -- P

Re: Monkeypatching a staticmethod?

2014-01-10 Thread Piet van Oostrum
Ian Kelly writes: > I suggest defining x as a normal function and writing the assignment > as "Foo.x = staticmethod(x)" to keep x callable from the global > namespace. Or just del it after doing the monkey patch. You can use Foo.x = staticmethod(lambda: 2) -- Piet van

Re: Bytes indexing returns an int

2014-01-09 Thread Piet van Oostrum
narrow-minded and Unicode > illiterate. They are neither of these things. > > Continuing to post these comments with no interest in learning is rude. > Other recent threads have contained details rebuttals of your views, > which you have ignored. This is rude. Please stop. Please ign

Re: the Gravity of Python 2

2014-01-09 Thread Piet van Oostrum
Chris Angelico writes: > On Fri, Jan 10, 2014 at 1:06 AM, Piet van Oostrum wrote: >> Chris Angelico writes: >> >>> On Thu, Jan 9, 2014 at 2:34 PM, Ben Finney >>> wrote: >>>> With time zones, as with text encodings, there is a single technically

Re: the Gravity of Python 2

2014-01-09 Thread Piet van Oostrum
; elegant solution (for text: Unicode; for time zones: twelve simple, >> static zones that never change) > > Twelve or twenty-four? Or are you thinking we should all be an even > number of hours away from UTC, which would also work? Even 24 doesn't take into account DST. -- Pie

Re: the Gravity of Python 2

2014-01-09 Thread Piet van Oostrum
utc from the doc and use that: from datetime import tzinfo, timedelta, datetime ZERO = timedelta(0) class UTC(tzinfo): """UTC""" def utcoffset(self, dt): return ZERO def tzname(self, dt): return "UTC" def dst(self, dt):

Re: Python/Django Extract and append only new links

2014-01-01 Thread Piet van Oostrum
r information with it also (and then it would be partly a Django problem because you would get the user id from Django). -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Python mange with liste

2013-12-29 Thread Piet van Oostrum
";"+r1 > > f=open("test.txt","r") > conten = f.read() > print conten > f.close() > > #f=open("test.txt","a") > #f.write(infos) > #f.write('\n') > #f.close() > > > thank you =) -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: python socket query

2013-12-23 Thread Piet van Oostrum
of 1 sec s.settimeout() call after the send call but it > doesnot help. > > I tried by commenting s.close() still it did not work. > > Any idea what is the problem? Length(reply) == 0 means that the other side closed the socket without sending anything back. -- Piet van Oostr

Re: If you continue being rude i will continue doing this

2013-11-18 Thread Piet van Oostrum
t helped a bit these would have been done in a couple of hours. How could anyone have known that this was the problem? AFIAK you didn't even tell about the VPS. And moreover this wasn't a Python problem, so off topic here. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Oh look, another language (ceylon)

2013-11-18 Thread Piet van Oostrum
ge reference manual rather than reading in detail.) So, yes, > they're O(n) operations. Thanks for hunting that down. > > ChrisA It would be so much better to use the Flexible String Representation. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: splitting file/content into lines based on regex termination

2013-11-09 Thread Piet van Oostrum
', '#9 /\n58#0#', '10178#000#C S#S#124##001##DAY#Computer Systems#Roper,\nPaul#3#MWF#11:00am#11:50am#1170 TMCB ', '#41 /\n145#0#', '10178#000#C S#S#124##002##DAY#Computer Systems#Roper,\nPaul#3#MWF#2:00pm#2:50pm#1170 TMCB ', '#40 /\n120#0#

Re: Adding 'download' column to existing 'visitors' table (as requested)

2013-11-08 Thread Piet van Oostrum
Sibylle Koczian writes: > Am 07.11.2013 14:14, schrieb Piet van Oostrum: >> Nick the Gr33k writes: >> >>> I have decided to take your advice. >>> I wasn't able to fit those 'lists' of mine into MySQL's varchar() >>> datatype afte

Re: Adding 'download' column to existing 'visitors' table (as requested)

2013-11-07 Thread Piet van Oostrum
use an extra table of downlaods that i asoociate with table > visitors with a foreing key but decided to add an additional 'download' > column into the existant visitors table: Nikos, you are an excellent member of the Greek society. Listening to you makes it so much easier to under

Re: Help me with this code

2013-11-07 Thread Piet van Oostrum
returns None. So the print sequence_b(10) dosn't make sense. If the print is only for debugging the use the following: def sequence_b(N): result = 0 for k in range (1,N): step = ((-1)**(k+1))/(2*k-1) print(step) ## debug output result += step return result

Re: Help me with this code PLEASE

2013-11-05 Thread Piet van Oostrum
CONVERT FROM LISTS TO LONG STRINGS SO I CAN STORE SUCCESSFULLY LIST > PYTHON DATATYPE TO MYSQL SCALAR STRING. > > EVERYHTIGN I TRIED FAILED. Then why don't you use the simple solution: use a relational database to store the data? -- Piet van Oostrum WWW: http://pietvanoostrum.c

Problem installing matplotlib 1.3.1 with Python 2.7.6 and 3.3.3 (release candidate 1)

2013-11-03 Thread Piet van Oostrum
ython should also include the Tcl/Tk header files. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-29 Thread Piet van Oostrum
sking for evidence you know you will never get. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: how to avoid checking the same condition repeatedly ?

2013-10-28 Thread Piet van Oostrum
he condition every time through the for loop, even though there > is no chance for needs_processing to change inside the loop, which does not > look very efficient. I bet in most cases you won't notice the time used to check the condition. Beware of premature optimization! -- Piet van Oost

Re: Cookie aint retrieving when visiting happens from a backlink.

2013-10-26 Thread Piet van Oostrum
Piet van Oostrum writes: > Νίκος Αλεξόπουλος writes: > >> There is no set of cookie returned back when visitor comes from a referer. >> >> Isn't this strange? >> No matter if you visit a webpage as a direct hit or via a referer the >> cookie on the v

Re: Cookie aint retrieving when visiting happens from a backlink.

2013-10-26 Thread Piet van Oostrum
my internet connection and then trying both the back button and entering the URL in the address bar. So it has nothing to do with referrer, I think. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: functools and objective usage

2013-10-22 Thread Piet van Oostrum
> functionality differ, Do you have experience with objective usage ? > http://docs.python.org/2/library/functools.html#partial-objects > What do you mean with "objective usage"? -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Front-end to GCC

2013-10-22 Thread Piet van Oostrum
mplete, it is not clear that > you will be able to compile it at all. That's the difference between > a calculator and a computer. You think a language that is not Turing-complete cannot be compiled? What nonsense is that. Please Mark, spare us your nonsense. -- Piet van Oostrum

Re: Python Front-end to GCC

2013-10-22 Thread Piet van Oostrum
Neil Cerutti writes: > > Context-sensitive grammars can be parse, too. > That's not English. Do you mean "parsed"? But context-sentitive grammars cannot be specified by BNF. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https:/

Re: Python Front-end to GCC

2013-10-22 Thread Piet van Oostrum
kens relate to each other. Syntax is grammar. Tokens are part of the grammar (but often specified separately with a different grammar, usually regular expressions, which is a subset of BNF). So are you just confused or are you trollong? -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Front-end to GCC

2013-10-21 Thread Piet van Oostrum
could make it easy. A language specification in BNF is just syntax. It doesn't say anything about semantics. So how could this be used to produce executable C code for a program? BNF is used to produce parsers. But a parser isn't sufficient. -- Piet van Oostrum WWW: http://pietvanoos

Re: ANN: matplotlib 1.3.1

2013-10-19 Thread Piet van Oostrum
Ned Deily writes: > In article , > Piet van Oostrum wrote: >> I tried to install it from source, on Mac OS X 10.6.8, with Python >> 3.3.2, and Tck/Tk 8.5 installed as Frameworks, but I get an error during >> compilation. It seems it doesn't find the Tcl/TK f

Re: ANN: matplotlib 1.3.1

2013-10-18 Thread Piet van Oostrum
with tcl.h from Tcl 8.5 lipo: can't figure out the architecture type of: /var/folders/5r/5r4ywY4e2ReN7U+8ZPQSJTI/-Tmp-//ccXN6p4b.out error: command 'gcc-4.2' failed with exit status 1 You have new mail in /var/mail/piet bash-3.2$ hg ftp -su -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Markers on a matplotlib plot

2013-10-17 Thread Piet van Oostrum
t.show() > > I would like to place markers on the 4 curves when the price is equal to $20 > label it A, and when the price is equal to $40 and label it B. Does anyone > know how I can accomplish this. Something like: plt.plot(20,40, 'bo') plt.annotate('B', (20,40), xytex

Re: Python was designed (was Re: Multi-threading in Python vs Java)

2013-10-17 Thread Piet van Oostrum
ors that translated into pure C code, which was then compiled with a C compiler. The resulting intermediate C code would be an object-oriented program in C. IIRC, the C code was reasonably clear, not really convoluted, so you would have been able to write it yourself. -- Piet van Oostrum WWW: http://piet

Re: Python was designed

2013-10-16 Thread Piet van Oostrum
ll due respect, Mark, your remarks are rubbish. Nobody talked about parsing input with binary switches except you. I answered that 40 years ago I wrote a parser generator that generated a parser for Algol 68 (and another one for Algol 60 I should have added). And all this was using punched cards.

Re: converting letters to numbers

2013-10-16 Thread Piet van Oostrum
IRC Lisp uses % for comments, but it may need to be doubled. (It's > been doubled in the examples I've seen, and I don't remember the > syntax.) > Perhaps Scheme has the same convention, but Scheme could be considered a > part of the Lisp clade. Lisp and scheme use

Re: urllib2 timeout issue

2013-10-16 Thread Piet van Oostrum
socket.setdefaulttimeout(5) > > and it didn't make any difference. > > In both cases, Python version is "Python 2.7.3". > > Am I missing something ? > I would guess the difference to be caused by DNS. Maybe the DNS configuration on the RPi is not optimal. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Python was designed

2013-10-15 Thread Piet van Oostrum
cc, that I did not know) and used it to generate a parser for Algol 68. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list

Re: Would you l like to take over lockfile?

2013-10-13 Thread Piet van Oostrum
Skip Montanaro writes: > I don't have the time or inclination to continue supporting lockfile ( > https://pypi.python.org/ > pypi/lockfile/). If you'd like to take it over, let me know. > > Skip Hi Skip, I am interested. -- Piet van Oostrum WWW: http://pi

  1   2   3   4   5   6   7   8   >