Re: repr( open('/etc/motd', 'rt').read() )

2016-02-15 Thread Steven D'Aprano
On Tuesday 16 February 2016 00:05, Veek. M wrote: > When I do at the interpreter prompt, > repr( open('/etc/motd', 'rt').read() ) Opening and reading MOTD is a needless distraction from your actual question. This demonstrates the issue most simply: # at the interactive interpreter py> s = "tex

Re: Make a unique filesystem path, without creating the file

2016-02-15 Thread Ben Finney
Cameron Simpson writes: > I've been watching this for a few days, and am struggling to > understand your use case. Yes, you're not alone. This surprises me, which is why I'm persisting. > Can you elaborate with a concrete example and its purpose which would > work with a mktemp-ish official fun

Re: asyncio - run coroutine in the background

2016-02-15 Thread Chris Angelico
On Mon, Feb 15, 2016 at 6:39 PM, Paul Rubin wrote: > "Frank Millman" writes: >> The benefit of my class is that it enables me to take the coroutine >> and run it in another thread, without having to re-engineer the whole >> thing. > > Threads in Python don't get you parallelism either, of course.

Project Xnod is created

2016-02-15 Thread wij
I am happy to announce that project Xnod is created. https://sourceforge.net/projects/systemnode/ Xnod tries to develop a more uniform language or scaffolding, or kind of program deployment to reduce efforts for nearly every programming tasks. Xnod is currently based on Xarg, and has to be a co

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-15 Thread John Ladasky
On Monday, February 15, 2016 at 6:02:24 PM UTC-8, Rick Johnson wrote: > On Friday, February 12, 2016 at 1:51:35 AM UTC-6, John Ladasky wrote: > > Reguarding a migration from Python2 to Pyhton3, John said: > > I had to wait until my favorite packages were ported > > (numpy, scipy, matplotlib, pand

Re: Make a unique filesystem path, without creating the file

2016-02-15 Thread Ben Finney
"Mario R. Osorio" writes: > I would create a RAM disk > (http://www.cyberciti.biz/faq/howto-create-linux-ram-disk-filesystem/), > generate all the path/files I want with any, or my own algorithm, run > the tests, unmount it, destroy it, be happy ... Whats wrong with > that?? It is addressing the

Re: Make a unique filesystem path, without creating the file

2016-02-15 Thread Mario R. Osorio
I would create a RAM disk (http://www.cyberciti.biz/faq/howto-create-linux-ram-disk-filesystem/), generate all the path/files I want with any, or my own algorithm, run the tests, unmount it, destroy it, be happy ... Whats wrong with that?? AFAIK, RAM disks do not get logged, and even if they do

Re: Changing sound volume

2016-02-15 Thread Rick Johnson
On Monday, February 15, 2016 at 4:58:04 AM UTC-6, izik43 wrote: > i had had to play some wav files and the volume was very > poor. i used "audacity" and used amplify effect to change > the basic amplitude. Yes, you can achieve a more powerful punch that way, but it's not the same as what the OP ne

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-15 Thread Chris Angelico
On Tue, Feb 16, 2016 at 1:02 PM, Rick Johnson wrote: >> But once that happened, I moved from Py2 to Py3 years ago >> with scarcely a bump, bruise, or scratch. > > So you have no Python2.x code remaining in your repos? Are > you telling us that you moved *EVERYTHING* to Python3? If > so, i can't im

Re: Make a unique filesystem path, without creating the file

2016-02-15 Thread Rick Johnson
On Sunday, February 14, 2016 at 10:55:11 PM UTC-6, Steven D'Aprano wrote: > If you want to guarantee that these faux pathnames can't > leak out of your test suite and touch the file system, > prepend an ASCII NUL to them. That will make it an illegal > path on all file systems that I'm aware of. H

Re: Make a unique filesystem path, without creating the file

2016-02-15 Thread Nobody
On Mon, 15 Feb 2016 15:28:27 +1100, Ben Finney wrote: > The behaviour is already implemented in the standard library. What I'm > looking for is a way to use it (not re-implement it) that is public API > and isn't scolded by the library documentation. So, basically you want (essentially) the exact

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-15 Thread Rick Johnson
On Friday, February 12, 2016 at 1:51:35 AM UTC-6, John Ladasky wrote: Reguarding a migration from Python2 to Pyhton3, John said: > I had to wait until my favorite packages were ported > (numpy, scipy, matplotlib, pandas). WxPython is not ported either, much to my chagrin. > But once that happen

Re: Make a unique filesystem path, without creating the file

2016-02-15 Thread Ben Finney
Roel Schroeven writes: > Use uuid.uuid1()? That has potential. A little counter-intuitive, for use in documentation about testing filesystem paths; but not frightening or dubious to the conscientious reader. I'll see whether that meets this use case, thank you. The bug report (to make a suppor

Re: Make a unique filesystem path, without creating the file

2016-02-15 Thread Thomas 'PointedEars' Lahn
Gregory Ewing wrote: > Ben Finney wrote: >> One valid filesystem path each time it's accessed. That is, behaviour >> equivalent to ‘tempfile.mktemp’. >> >> My question is because the standard library clearly has this useful >> functionality implemented, but simultaneously warns strongly against i

Re: Make a unique filesystem path, without creating the file

2016-02-15 Thread Cameron Simpson
On 15Feb2016 12:19, Ben Finney wrote: Dan Sommers writes: On Mon, 15 Feb 2016 11:08:52 +1100, Ben Finney wrote: > I am unconcerned with whether there is a real filesystem entry of > that name; the goal entails having no filesystem activity for this. > I want a valid unique filesystem path, wit

Re: Make a unique filesystem path, without creating the file

2016-02-15 Thread Roel Schroeven
Ben Finney schreef op 2016-02-14 22:46: How should a program generate a unique filesystem path and *not* create the filesystem entry? > ... What standard library function should I be using to generate ‘tempfile.mktemp’-like unique paths, and *not* ever create a real file by that path? Use uui

Re: Syntax error (The Python Book) Linux User and Developer Bookazine

2016-02-15 Thread Larry Hudson via Python-list
On 02/15/2016 07:06 AM, Joel Goldstick wrote: [snip a lot...] Learn Python the Hard Way is pretty good some people say. Its online. Also Diving into Python is online written by the now offline Mark Pilgrim. I have a couple of "Hard Way" books and personally, I don't like his style of teachin

Re: repr( open('/etc/motd', 'rt').read() )

2016-02-15 Thread Terry Reedy
On 2/15/2016 8:05 AM, Veek. M wrote: When I do at the interpreter prompt, repr( open('/etc/motd', 'rt').read() ) i get # 1 #: When posting questions here or at Stackoverflow or elsewhere, it is a really good idea to develop and post a 'minimal, complete, verifiable example' that demonstrates

Re: What is heating the memory here? hashlib?

2016-02-15 Thread Paulo da Silva
Às 08:12 de 15-02-2016, Johannes Bauer escreveu: > On 15.02.2016 03:21, Paulo da Silva wrote: > >> So far I tried the program twice and it ran perfectly. > > I think you measured your RAM consumption wrong. > > Linux uses all free RAM as HDD cache. That's what is used in "buffers". > That is, it

Re: Unable to insert data into MongoDB.

2016-02-15 Thread Peter Otten
Arjun Srivatsa wrote: > Hi Peter. > > Thank you for the reply. > > This is the read_server code: > > import socket > from pymongo import MongoClient > #import datetime > import sys > > # Connection to server (PLC) on port 27017 > host = "10.52.124.135" > port = 27017 > > s = socket.socket(soc

Re: Make a unique filesystem path, without creating the file

2016-02-15 Thread Grant Edwards
On 2016-02-15, Ben Finney wrote: > Dan Sommers writes: > >> On Mon, 15 Feb 2016 11:08:52 +1100, Ben Finney wrote: >> >> > I am unconcerned with whether there is a real filesystem entry of >> > that name; the goal entails having no filesystem activity for this. >> > I want a valid unique filesyste

Re: Make a unique filesystem path, without creating the file

2016-02-15 Thread Grant Edwards
On 2016-02-14, Ben Finney wrote: > Howdy all, > > How should a program generate a unique filesystem path and *not* create > the filesystem entry? Short answer: you can't because it's the filesystem entry operation that is atomic and guarantees uniqueness. > [..] > What standard library function

Re: Syntax error (The Python Book) Linux User and Developer Bookazine

2016-02-15 Thread Geoff Munn
On Monday, 15 February 2016 15:07:03 UTC, Joel Goldstick wrote: > On Mon, Feb 15, 2016 at 9:56 AM, Geoff Munn wrote: > > > On Sunday, 14 February 2016 13:39:52 UTC, Geoff Munn wrote: > > > Hi, > > > > > > Noob at the Python thing so here goes, > > > > > > I have copied a program to demonstrate

Re: Unable to insert data into MongoDB.

2016-02-15 Thread Arjun Srivatsa
Okay, I added with open('yourfile','w') as f: f.write(data) to the read_server code in which the Actual data is stored in a file on my desktop. Then, it must be possible to read this file in the Write_db script to insert the data. On Monday, February 15, 2016 at 4:00:37 PM UTC+1, Arjun

Re: Syntax error (The Python Book) Linux User and Developer Bookazine

2016-02-15 Thread Joel Goldstick
On Mon, Feb 15, 2016 at 9:56 AM, Geoff Munn wrote: > On Sunday, 14 February 2016 13:39:52 UTC, Geoff Munn wrote: > > Hi, > > > > Noob at the Python thing so here goes, > > > > I have copied a program to demonstrate control structures in Python but > get a syntax error at line 31, isint = False.

Re: Unable to insert data into MongoDB.

2016-02-15 Thread Arjun Srivatsa
Hi Peter. Thank you for the reply. This is the read_server code: import socket from pymongo import MongoClient #import datetime import sys # Connection to server (PLC) on port 27017 host = "10.52.124.135" port = 27017 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, por

Re: Syntax error (The Python Book) Linux User and Developer Bookazine

2016-02-15 Thread Geoff Munn
On Sunday, 14 February 2016 13:39:52 UTC, Geoff Munn wrote: > Hi, > > Noob at the Python thing so here goes, > > I have copied a program to demonstrate control structures in Python but get a > syntax error at line 31, isint = False. I'm using Python 2.7.6 and Linux Mint > based around ubuntu14

Re: repr( open('/etc/motd', 'rt').read() )

2016-02-15 Thread Random832
On Mon, Feb 15, 2016, at 08:05, Veek. M wrote: > What is happening with # 1 # (repr)? > repr calls __repr__ which gives you bytes.. why does this result in \\n When you call a function that returns a string directly in the interpreter prompt (i.e. without print), it passes the result to repr, whic

Re: There has to be a better way to split this string!

2016-02-15 Thread Emile van Sebille
On 2/9/2016 10:50 PM, Cameron Simpson wrote: On 10Feb2016 07:34, srinivas devaki wrote: PS: trying to read mailing list when you are half woke, is a bad idea and trying reply to it is even bad idea. Regrettably, when one is half awake one is unable to realise what a bad idea it may be:-)

repr( open('/etc/motd', 'rt').read() )

2016-02-15 Thread Veek. M
When I do at the interpreter prompt, repr( open('/etc/motd', 'rt').read() ) i get # 1 #: "'\\nThe programs included with the Debian GNU/Linux system are free software;\\nthe exact distribution terms for each program are described in the\\nindividual files in /usr/share/doc/*/copyright.\\n\\nDe

Re: Unable to insert data into MongoDB.

2016-02-15 Thread Peter Otten
Arjun Srivatsa wrote: > I changed the port number from 27017 to 5 in the code segment: Instead of throwing arbitrary changes at your script in the hope that one works I recommend that you write two independent scripts, from scratch: (1) write_to_db.py: Write made-up data into the MongoDB o

Re: asyncio - run coroutine in the background

2016-02-15 Thread Marko Rauhamaa
Paul Rubin : > Threads in Python don't get you parallelism either, of course. Ah, of course. Processes it is, then. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Changing sound volume

2016-02-15 Thread izik43
i had had to play some wav files and the volume was very poor. i used "audacity" and used amplify effect to change the basic amplitude. -- https://mail.python.org/mailman/listinfo/python-list

Re: Unable to insert data into MongoDB.

2016-02-15 Thread Arjun Srivatsa
I changed the port number from 27017 to 5 in the code segment: IP = "127.0.0.1" PORT = 27017 BUFFER_SIZE = 1024 client = MongoClient('127.0.0.1', 27017) And my output on Python shell is: hello world! Connection address: ('127.0.0.1', 16951) Connection address: ('127.0.0

Re: ftplib throws: IndexError: tuple index out of range

2016-02-15 Thread Peter Otten
Antoon Pardon wrote: >> PS: How did you produce the overview over the local variables? That looks >> nice. > I started from this recipe: > http://code.activestate.com/recipes/52215-get-more-information-from-tracebacks/ > made it more to my liking and turned it into a module. So that instead of >

Re: ftplib throws: IndexError: tuple index out of range

2016-02-15 Thread Peter Otten
Antoon Pardon wrote: >> It looks like the actual error is socket.timeout which is probably raised >> from somewhere inside the stdlib without args. > > I think I know what is going on. I have my own timeout mechanism at work > here, that works with signals and alarm. When the SIGALRM fires I just

Re: fetchall is taking much longer time while getting data from Sybase module in Python

2016-02-15 Thread Peter Otten
reetesh nigam wrote: > Hi All, > > I am retrieving data from Sybase database using Sybase module of Python. > My query is not taking time however fecthall is taking longer time. > > Below is the test script : > > def run_query(db,query): ## Run query and resturn record result > t1 = dat

Re: How to properly override the default factory of defaultdict?

2016-02-15 Thread Gregory Ewing
Herman wrote: I want to pass in the key to the default_factory of defaultdict and I found that defaultdict somehow can intercept my call to dict.__getitem__(self, key), What's happening here is that defaultdict doesn't actually override __getitem__ at all. Instead, it overrides __missing__, whi

EuroPython 2016: Sending out the first gravitational waves

2016-02-15 Thread M.-A. Lemburg
We are pleased to announce the launch of our all new EuroPython 2016 website. Over the last few weeks, we have been busy talking to sponsors and getting the website prepared for the launch. You may have heard about the recent direct observation of gravitational waves by the LIGO (Laser Interferome

Re: asyncio - run coroutine in the background

2016-02-15 Thread Frank Millman
"Paul Rubin" wrote in message news:87h9ha8lt0@jester.gateway.pace.com... "Frank Millman" writes: > The benefit of my class is that it enables me to take the coroutine > and run it in another thread, without having to re-engineer the whole > thing. Threads in Python don't get you paralleli

Re: What is heating the memory here? hashlib?

2016-02-15 Thread Johannes Bauer
On 15.02.2016 03:21, Paulo da Silva wrote: > So far I tried the program twice and it ran perfectly. I think you measured your RAM consumption wrong. Linux uses all free RAM as HDD cache. That's what is used in "buffers". That is, it's not "free", but it would be free if any process would sbrk().

Re: Make a unique filesystem path, without creating the file

2016-02-15 Thread Gregory Ewing
Ben Finney wrote: The existing behaviour of ‘tempfile.mktemp’ – actually of its internal class ‘tempfile._RandomNameSequence’ – is to generate unpredictable, unique, valid filesystem paths that are different each time. But that's not documented behaviour, so even if mktemp() weren't marked as

Re: What is heating the memory here? hashlib?

2016-02-15 Thread Paulo da Silva
Às 02:21 de 14-02-2016, Steven D'Aprano escreveu: > On Sun, 14 Feb 2016 06:29 am, Paulo da Silva wrote: ... Thanks Steven for your advices. This is a small script to solve a specific problem. It will be used in future to solve other similar problems probably with small changes. When I found it eat

Re: Make a unique filesystem path, without creating the file

2016-02-15 Thread Gregory Ewing
Ben Finney wrote: One valid filesystem path each time it's accessed. That is, behaviour equivalent to ‘tempfile.mktemp’. My question is because the standard library clearly has this useful functionality implemented, but simultaneously warns strongly against its use. But it *doesn't*, if your r