Re: Distributing program for Linux

2023-03-15 Thread Anssi Saari
"Loris Bennett"  writes:

> I am aware that an individual user could use (mini)conda to install a
> more recent version of Python in his/her home directory, but I am
> interested in how root would install such a program.

Root would install the script and required Python version somewhere
depending any site specific practices and then use things like pyenv,
stow, environment modules or whatever to give the users access to it.

Root might even package your script with the interpreter required into
one binary. See Tools/freeze in the source distribution.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Usenet vs. Mailing-list

2023-01-31 Thread Anssi Saari
Grant Edwards  writes:

> No. FWIW, it's the mailing list that's blocking them, not Gmane.
>
> That's why I wrote this:
>
> https://github.com/GrantEdwards/hybrid-inews
>
> It's an inews work-alike that submits most posts via gmanes NNTP
> server, but will deal with particular groups
> (e.g. gmane.comp.python.general) that want posts submitted via email.
>
> It allows me to continue to read (and post to) the Python mailling
> list via slrn pointed at gmane.

Interesting. In Gnus it was just a couple of settings to make it
understand that in this group (i.e. gmane group
gmane.comp.python.general) posts and follow-ups should be sent via mail
to the mailing list address.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 'äÄöÖüÜ' in Unicode (utf-8)

2022-04-07 Thread Anssi Saari
Dennis Lee Bieber  writes:

> On Fri, 1 Apr 2022 03:59:32 +1100, Chris Angelico 
> declaimed the following:
>
>
>>That's jmf. Ignore him. He knows nothing about Unicode and is
>>determined to make everyone aware of that fact.
>>
>>He got blocked from the mailing list ages ago, and I don't think
>>anyone's regretted it.

>   Ah yes... Unfortunately, when gmane made the mirror read-only, I had to
> revert to comp.lang.python... and all the junk that gets in via that and
> Google Groups...

Hm. I just configured my news reader to send follow-ups to the mailing
list when that happened.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Scope confusion in Python REPL

2022-01-13 Thread Anssi Saari
Chris Angelico  writes:

> When you import something, all you're doing is getting a local
> reference to it; "from foo import make_adder" is basically like saying
> "import foo; make_adder = foo.make_adder". The function itself is
> still the same, and it still remembers its original context.

Thanks, this clears it up.

The pattern matching examples that I was looking at when I got confused
are at
https://mathspp.com/blog/pydonts/pattern-matching-tutorial-for-pythonic-code
in case anyone is interested. Fairly neat stuff in my opinion.
-- 
https://mail.python.org/mailman/listinfo/python-list


Scope confusion in Python REPL

2022-01-13 Thread Anssi Saari


I ran into what seems odd scoping to me when playing with some matching
examples for 3.10.

I kinda thought that if I do from foo import * and from bar import * in
the Python REPL, I'd get everything from foo and bar in the main
scope. Or whatever the scope is at the prompt.

And yet, if I define function foo in module foo and function bar in
module bar and import as above, I can't call function bar from function
foo. But if I define functions foo and bar at the prompt, then I can. So
what's the difference in scoping here?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to package a Python command line app?

2021-12-10 Thread Anssi Saari
Manfred Lotz  writes:

> pyinstaller worked fine taking care of message.py and typer module. But
> as said in my other reply it is glibc version dependent.

Perhaps the included freeze.py script (included in the CPython source
that is, in Tools/freeze) is worth considering as well. Although it also
seems to create a dynamic executable by default (I tried with your hello
example), it seems to me it's possible to edit the generated makefile
and replace -shared with -static in a few places. Didn't try that
though.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trying to read from a text file to generate a graph

2021-07-29 Thread Anssi Saari
"Steve"  writes:

> I am going though a struggle with this and just don't see where it fails.

It seems to me you're putting your data into strings when you need to
put it into lists. And no, adding brackets and commas to your strings so
that printing out the strings makes them look like lists doesn't make
them into lists.

There's python tutorial at https://docs.python.org/3/tutorial/index.html
which may help with the basics.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Application problems

2021-03-11 Thread Anssi Saari
Thomas Jollans  writes:

> On 10/03/2021 21:50, Mats Wichmann wrote:
>>
>> For the first one, don't feel too bad, this ("opening the normal
>> python") seems to be biting a lot of people recently
>
>
> I wonder why. Python's installation process isn't any different from
> most other Windows software released the past 25-ish years. Is it
> possible that Windows 10's search feature sometimes makes poor
> choices, and typing "python" just brings up the wrong thing?

I'm thinking maybe it's people who've never installed anything? Since
for Facebook or whatever you only need a browser...

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why do I have both /usr/lib/python3 and /usr/lib/python3.8?

2020-12-30 Thread Anssi Saari
Chris Green  writes:

> Why are there both /usr/lib/python3 and /usr/lib/python3.8 on my
> x[ubuntu] system?

While it's more of an Ubuntu (or Debian) question better asked in some
relevant Linux forum, in the end it's because some package managers
decided to do that. You can use commands like these to see which
packages put stuff in which directory:

dpkg -S /usr/lib/python3.8
dpkg -S /usr/lib/python3

On my Debian system the corresponding output looks like this:

$ dpkg -S /usr/lib/python3.7
python3.7, libpython3.7-minimal:amd64, python3-tk:amd64,
libpython3.7-dev:amd64, libpython3.7-stdlib:amd64, libpython3.7:amd64,
python3-distutils, python3-lib2to3: /usr/lib/python3.7

$ dpkg -S /usr/lib/python3  
python3-scipy, python3-opengl, python3-statsmodels, iotop,
python3-reportlab-accel:amd64, python3-magic, python3-pkg-resources,
python3-kiwisolver, python3.7, python3-pandas-lib, python3-kerberos,
python3-lz4, python3-renderpm:amd64, python3-numexpr,
python3-cffi-backend, python3-crypto, python3-tables, python3-rencode,
python3-gi, python3-dbus, devscripts, python3-gpg, python3-pyasn1,
python3-py, python3-eyed3, pdfarranger, python3-pip, python3-virtualenv,
xpra, python3-pandas, python3-pil:amd64, python3-requests,
python3-urllib3, python3-psutil, python3-paramiko, python3-netifaces,
python3-patsy, python3-gssapi, python3-sklearn, python3-cycler,
python3-sip, python3-cairo:amd64, python3-six, python3-chardet,
python3-nose, python3-debian, python3-wheel, python3-attr,
python3-soupsieve, python3-bcrypt, python3-bs4, python3-sklearn-lib,
python3-scour, python3-setuptools, python3-entrypoints,
python3-gi-cairo, python3-cups, python3-keyrings.alt, python3-pluggy,
python3-tz, python3-ifaddr, python3-joblib, python3-cvxopt,
python3-secretstorage, python3-reportlab, python3-more-itertools,
python3-keyring, python3-asn1crypto, python3-html5lib, python3-dns,
python3-decorator, python3-dateutil, meson, python3-pexpect,
python3-idna, python3-seaborn, lsb-release, python3-numpy,
python3-brotli, python3-tables-lib, python3-lxml:amd64, python3-pytest,
python3-simplejson, python3-nacl, python3-zeroconf, python3-xdg,
python3-libvoikko, python3-gst-1.0, python3-pypdf2, python3-evdev,
python3-matplotlib, python3-statsmodels-lib, python3-cryptography,
python3-certifi, python3-atomicwrites, python3-pyparsing,
python3-ptyprocess, python3-webencodings, piper, python3-uno,
python3-apt, python3-setproctitle:amd64, hplip: /usr/lib/python3

So I'd say as a rule stuff relevant to the specific version of python
goes in the specific version directory (i.e. /usr/lib/python3.8 in your
case) and python software packages in general go in /usr/lib/python3.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please help test astral char display in tkinter Text (especially *nix)

2020-11-06 Thread Anssi Saari
Terry Reedy  writes:

> Perhaps half of the assigned chars in the first plane are printed
> instead of being replaced with a narrow box. This includes emoticons
> as foreground color outlines on background color.  Maybe all of the
> second plane of extended CJK chars are printed.  The third plane is
> unassigned and prints as unassigned boxes (with an X).

I get the same as Menno Holscher (i.e. messages with "character is above
the range blah blah") in Debian 10 with the system provided Python
3.7.3. Tcl and tk are 8.6.9.

With Python 3.9.0 I get something like what you described above. Some
chars print, lots of empty boxes too and lots of just empty space. No
boxes with an X and no errors.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing Python 3.8.3 with tkinter

2020-07-23 Thread Anssi Saari
Klaus Jantzen  writes:

> On 7/22/20 11:05 PM, Ned Deily wrote:
>> On 2020-07-22 06:20, Klaus Jantzen wrote:
>>> Trying to install Python 3.8.3 with tkinter I run configure with the
>>> following options
>>>
>>> ./configure --enable-optimizations --with-ssl-default-suites=openssl
>>> --with-openssl=/usr/local --enable-loadable-sqlite-extensions
>>> --with-pydebug --with-tcltk-libs='-L/opt/ActiveTcl-8.6/lib/tcl8.6'
>>> --with-tcltk-includes='-I/opt/ActiveTcl-8.6/include'
>>>
>>> Running Python gives the following information
>> [...]
>>> How do that correctly?
>> Try --with-tcltk-libs='-L/opt/ActiveTcl-8.6/lib -ltcl8.6 -ltk8.6'
>>
>>
> Thank you for your suggestion; unfortunately it did not help.

Are you sure the libs you need (presumably libtcl8.6.so and libtk8.6.so)
are both in /opt/ActiveTcl-8.6/lib/tcl8.6? Or where are they actually?
Presumably not in /opt/ActiveTcl-8.6/lib since that didn't work.

Could be something else too. You may need to dig into setup.py and the
configure script.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Your IDE's?

2019-03-27 Thread Anssi Saari
Ben Finney  writes:

> Emacs and a shell multiplexer (today, that's GNU Screen, but others
> swear that I should try TMux).

I've actually been using tmux for a while. The only reason and the only
thing I can think of that it does and screen doesn't is that tmux can
display italic text and screen apparently can't. So I went with tmux for
Usenet.

Well, there were some claims from tmux about it being a better terminal
but I can't really see a difference.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem in Installing version 3.7.2(64 bit)

2019-01-30 Thread Anssi Saari
songbird  writes:

>   my understanding is that this list is actually 
> several combined services (i'm not sure how the
> mailing list operates or how it filters or rejects
> things) and then there is the usenet list comp.lang.python
> (which is how i see articles and replies).

I'm aware but the message was sent to the mailing list and it's the
mailing list that removes attachments. I suppose some Usenet servers
might strip or reject articles that look like binaries, don't really
know. I do think it extremely unlikely a beginner would send a Usenet
post except maybe via Google Groups but that interface doesn't do
attachments AFAIK.

As the mailing list has moderators and they have recently flexed their
muscles by outright banning people I'm hoping they would stop these
attachment posts too. This would stop the oft repeated responses that
attachments are stripped which I find annoying.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem in Installing version 3.7.2(64 bit)

2019-01-29 Thread Anssi Saari
Terry Reedy  writes:

> On 1/26/2019 6:24 AM, Vrinda Bansal wrote:
>> Dear Sir/Madam,
>>
>> After Installation of the version 3.7.2(64 bit) in Windows 8 when I run the
>> program it gives an error. Screenshot of the error is attached below.
>
> Nope.  This is text only mail list.  Images are tossed.  You must copy
> and paste.

Just curious, but wouldn't it be better to just reject messages with
attachments instead of silent removal? I suppose the end result is
mostly the same for the person asking but the rest of us would be
spared.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: building 3.7.1 from source, _ctypes and libffi troubles

2018-12-21 Thread Anssi Saari
"Fetchinson . via Python-list"  writes:

> And as far as I know pkg-config is used by python's configure script
> so everything should be fine. I also set
> LD_LIBRARY_PATH=/home/fetch/opt/lib:/home/fetch/opt/lib64 and also
> C_INCLUDE_PATH=/home/fetch/opt/include

I looked into this a little. I found that setting C_INCLUDE_PATH as you
did disables finding libffi headers since pkg-config prints nothing with
pkg-config --cflags libffi then and it seems the headers are found with
pkg-config.

As for the libraries, detect_modules() in setup.py wants to find extra
library directories from the generated makefile so you need to make sure
they actually go in there, like this for example:

LDFLAGS=`pkg-config --libs-only-L libffi` ./configure

Then you'll have CONFIGURE_LDFLAGS and PY_LDFLAGS set in the generated
makefile and setup.py will pick up the directory from there.

Anyways, hope it helps. This worked for me on Ubuntu 16.04.5 LTS.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-12 Thread Anssi Saari
Chris Angelico  writes:

> On Fri, Nov 9, 2018 at 11:11 PM Anssi Saari  wrote:
>>
>> Chris Angelico  writes:
>>
>> > No helper needed. Safe against command injection. Uses the known
>> > format of the command's output; if you want other information as well
>> > as the type, you could get that too.
>>
>> Can someone let me in on this secret helper module? Doesn't seem to
>> match the helper module in PyPI at least.
>>
>
> What helper? 

Helper module used in the original post. I assumed you know what it is
since you declared it's not needed.

> I said you don't need one. Just use subprocess directly.

This part was clear. 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-09 Thread Anssi Saari
Chris Angelico  writes:

> No helper needed. Safe against command injection. Uses the known
> format of the command's output; if you want other information as well
> as the type, you could get that too.

Can someone let me in on this secret helper module? Doesn't seem to
match the helper module in PyPI at least.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Type error: not enough arguments for format string

2018-09-20 Thread Anssi Saari
Cameron Simpson  writes:

> On 19Sep2018 09:12, synch1...@gmail.com  wrote:
>>I'm just trying to follow along with the logging tutorial documentation and I 
>>am getting this error:
>>
>>import logging
>>
>>logging.basicConfig(format= '%(asctime)s % (message)s', datefmt='%m%d%Y 
>>%I:%M:%S %p')
>
> Probably this:  --^^
>
> The space after the "%" in "% (message)s" is preventing correct
> recognision of the format.

Yes. It makes sense to copy-paste examples instead of typing them in. I
guess the original is from
https://docs.python.org/2/howto/logging.html#changing-the-format-of-displayed-messages
and it doesn't have the extra space which is a problem here.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: CURSES WINDOWS

2018-09-06 Thread Anssi Saari
Peter via Python-list  writes:

>>     from _curses import *
>> ModuleNotFoundError: No module named '_curses'

Oh yes, I tested in Cygwin and maybe it doesn't count? But for Windows
there's a curses wheel available at
https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: CURSES WINDOWS

2018-09-05 Thread Anssi Saari
shinobi@f153.n1.z21.fsxnet (shinobi) writes:

> Hello All,
>
> can anyone please let me know what's the path to port linux python curses
> program to Windows?

Is there really anything that needs to be done? At least a simple hello
world python curses program runs on Windows and Linux with no changes.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Feeding the trolls

2018-06-21 Thread Anssi Saari
D'Arcy Cain  writes:

> One of these days I will have to figure out how to block replies to the
> trolls as well.

Benefit of reading the mailing list via nntp (i.e. gmane): can easily
score down follow-ups to annoying people in addition to their
posts. Well, assuming a decent newsreader.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt4 QWebView cant load google maps markers

2018-03-23 Thread Anssi Saari
Xristos Xristoou  writes:

> I want to create a simple python app using pyqt,QWebView and google maps with 
> markers.
>
> The problem is that,the markers does not load inside the QWebView, as
> you can see they load just fine in the browser.

Well, since you got a javascript error, maybe Qt4 doesn't support the
version of javascript Google uses today? Qt4 was released over a decade
ago.

I tried with PyQt5 and the page loads and a marker shows up. It then
disappears as Google puts up a couple of popups. There's a complaint
about browser capabilities and also a privacy note from Google.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Respam levels.

2018-02-14 Thread Anssi Saari
Mark Lawrence  writes:

>> This may be the result of a misconfigured spam filter, or an actual spam
>> attack; anyway, I've now filtered news.bbs.geek.nz from my feed.
>>
> IIRC the same source for the "nospam" stuff of some months ago which I
> believe was purely accidental.

It's kinda funny, back in the 90s Usenet was spammed every now and again
by various misconfigured BBS's running a Usenet gateway. Usually sending
all messages back from every group to every group. I thought BBS's are
fairly dead and Usenet is mostly gone too but apparently this downside
has made a comeback.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where are the moderators?

2018-01-19 Thread Anssi Saari
Skip Montanaro  writes:

> Neither works for me. The news link clearly fails, but the gmane.org
> link has no search functionality either. Do you have a direct URL to
> comp.lang.python?

Gmane seems to be in the middle of a massive rebuild at the
moment. Comp.lang.python's webpage is
http://dir.gmane.org/gmane.comp.python.general but none of the links to
read or search the list seem to be working at the moment. NNTP access to
news.gmane.org and group gmane.comp.python.general works for me. For
reading at least, I don't know if this message goes anywhere...

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Generating SVG from turtle graphics

2018-01-15 Thread Anssi Saari
Peter Otten <__pete...@web.de> writes:

> Then convert to SVG with an external tool. It looks like ghostscript can do
> that:
>
> $ gs -dBATCH -dNOPAUSE -sDEVICE=svg -sOutputFile=tmp_turtle.svg tmp_turtle.ps

And if not (I at least don't have svg output on three ghostscripts I
tried), pstoedit can do it too.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Good virtualenv and packaging tutorials for beginner?

2017-10-06 Thread Anssi Saari
Leam Hall  writes:

> Folks on IRC have suggested using virtualenv to test code under
> different python versions. Sadly, I've not found a virtualenv tutorial
> I understand. Anyone have a link to a good one?

I recently used
http://www.simononsoftware.com/virtualenv-tutorial-part-2/ to set up
one. I was mostly trying to see if I could use it to install current
Python 3 to an oldish Debian system. Worked fine.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: comp.lang.python killfile rule

2017-06-26 Thread Anssi Saari
John Black  writes:

> All, in case this is useful to anyone, this rule that tells my newsreader 
> which posts to kill really cleans up the group.

I get by just with a very old rule that lowers the score of articles
where the subject is in all caps. Those articles end up in the bottom of
the article list with the other crap and are easily ignored.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Data exchange between python script and bash script

2017-04-05 Thread Anssi Saari
venkatachalam...@gmail.com writes:

> For example, the data is printed in
> execute_sensor_process.py as follows:
>
> print >>sys.stderr,sens_data
>
> By printing the data onto sys.stderr and assigning a return variable in the 
> bash, I am expecting the data to be assigned.
>
> But this is not happening.

This part I can answer alhtough I'm not sure it helps with your actual
problems. 

Bash manual explicitly states command substition (the $(...) structure)
replaces the command with the standard *output* of the command. So since
your Python program writes to standard error, you get nothing.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] Security question

2016-12-30 Thread Anssi Saari
"Frank Millman"  writes:

> Hi all
>
> This is off-topic, but I would appreciate a comment on this matter.
>
> I have just upgraded my internet connection from ADSL to Fibre.
>
> As part of the process, my ISP sent a text message to my cell phone
> with the username and password I must use to connect.
>
> To my surprise, they sent me my existing username *and* my existing
> password, all in clear text.

I'd say it depends on what the password is actually used for. You seem
to indicate it's just so you can access the internet? To me it seems
abusing that password is hard to impossible since it's your fibre to
your home. If the password is used for access control for anything then
it's an awful practise.

In my case, I have one password for the email account my ISP provides
and another for their web management pages where I can buy more or get
rid of services and see my bills and such.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Request Help With Byte/String Problem

2016-11-30 Thread Anssi Saari
Wildman via Python-list  writes:

> On Tue, 29 Nov 2016 18:29:51 -0800, Paul Rubin wrote:
>
>> Wildman  writes:
>>> names = array.array("B", '\0' * bytes)
>>> TypeError: cannot use a str to initialize an array with typecode 'B'
>> 
>> In Python 2, str is a byte string and you can do that.  In Python 3,
>> str is a unicode string, and if you want a byte string you have to
>> specify that explicitly, like b'foo' instead of 'foo'.  I.e.
>> 
>>  names = array.array("B", b'\0' * bytes)
>> 
>> should work.
>
> I really appreciate your reply.  Your suggestion fixed that
> problem, however, a new error appeared.  I am doing some
> research to try to figure it out but no luck so far.
>
> Traceback (most recent call last):
>   File "./ifaces.py", line 33, in 
> ifs = all_interfaces()
>   File "./ifaces.py", line 21, in all_interfaces
> name = namestr[i:i+16].split('\0', 1)[0]
> TypeError: Type str doesn't support the buffer API

It's the same issue and same fix. Use b'\0' instead of '\0' for the
argument to split().

There'll be a couple more issues with the printing but they should be
easy enough.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Quick help for a python newby, please

2016-11-23 Thread Anssi Saari
jones.day...@gmail.com writes:

> but how do I replace the "2008, 8, 18" and "2008, 9, 26" with *my* values?  
> I've tried several things (which I can't remember all of) but usually end up 
> with an error like this:

Something like this?

today = date.today()
birthday = date(byear, bmonth, bday)
delta = today - birthday
print(delta.days)


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [PyQT] After MessageBox app quits...why?

2016-11-07 Thread Anssi Saari
Demosthenes Koptsis  writes:

> Hello, i have a PyQT systray app with a menu and two actions.
>
> Action1 is Exit and action2 display a MessageBox with Hello World message.
>
> When i click OK to MessageBox app quits...why?
>
> http://pastebin.com/bVA49k1C

I haven't done anything with Qt in a while but apparently you need to
call QtGui.QApplication.setQuitOnLastWindowClosed(False) before
trayIcon.show().
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: function call questions

2016-10-21 Thread Anssi Saari
"Frank Millman"  writes:

> Let's see if I can explain. I am using 't' and 'r' instead of 'tree'
> and 'root', but otherwise it is the same as your original example.
>
 t = {}
 r = t
 id(t)
> 2542235910088
 id(r)
> 2542235910088
>
> At this point, t and r are both references to the same empty dictionary.
>
 r = r.setdefault('a', {})
>
> This has done two things.
>
> It has inserted the key 'a' into the dictionary, and set its value to {}.
>
 t
> {'a': {}}
 id(t)
> 2542235910088
>
> It has also rebound 'r' so that it now references the new empty
> dictionary that has been inserted.

I guess this is where I fell of the wagon previously. I got it now.

 r
> {}
 id(r)
> 2542234429896
t['a']
> {}
 id(t['a'])
> 2542234429896
>
> Now continue this process with r = r.setdefault('b', {}), and watch
> what happens.

OK, so what happens is that now t references the dictionary with 
{'a': {}} and r references the empty dict inside that. So when we assign to r
again, it's the empty dict inside t (the one accessed by key 'a') that
changes to {'b': {}} and t becomes {'a': {'b': {}}}.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: function call questions

2016-10-18 Thread Anssi Saari
chenyong20...@gmail.com writes:

> My question is:
> (1) why root is always {}?

Because that's what you wrote. root.setdefault(ch, {}) returns {} and
you assign that to root. You probably want to do just
root.setdefault(ch, {}) instead of root = root.setdefault(ch, {}).

> (2) why tree is {'a': {'b': {'c': {?

That I don't know. Seems odd to me. From some debugging it seems that
after root = root.setdefault(ch,{}) tree['a'] and root are the same
object. So on the second round your code calls
tree['a'].setdefault('b',{}) and on the third round
tree['a'].setdefault('c',{}) which results in {'a': {'b': {'c': { as
the value of tree.

> (3) why root isn't the same as tree? shouldn't they be the same because tree 
> is argument passed as root?

They are the same until you bind root to a new object with root =
root.setdefault(ch,{}).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Static typing implementation for Python

2015-10-12 Thread Anssi Saari
Chris Angelico  writes:

> I'm fairly sure most arguments about "readable" or "unreadable" code
> follow the same definitions.

Does it ever. I never thought annotating names one added with one's
initials or copy-pasting code instead of having a boolean expression in
an if statement or keeping old code as comments improve readability. But
that's what I was just told recently by someone. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question re class variable

2015-09-29 Thread Anssi Saari
Antoon Pardon  writes:

> Op 29-09-15 om 11:27 schreef ple...@gmail.com:
>> I have a perplexing problem with Python 3 class variables. I wish to
>> generate an unique ID each time an instance of GameClass is
>> created. There are two versions of the __gen_id method with test run
>> results for each listed below the code.
>
> The problem is that in python you can't change a class variable through an 
> instance. The moment you
> try, you create an instance attribute.

That much is clear but why does his other version of __gen_id() work
(after a fashion)? It doesn't increment the class variable but the
instances get an incremental id.

The function was like this:

def __gen_id(self):
ty = self.__class__.__name__
id = ''
while id in self.__instance_registry:
id = '%s_%d' % (ty, self.__instance_counter)
self.__instance_counter += 1
self.__instance_registry[id] = self
return id

Also, is there any problem with incrementing
GameObject.__instance_counter from __gen_id()? I guess not?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python, convert an integer into an index?

2015-09-24 Thread Anssi Saari
Dennis Lee Bieber  writes:

> On Wed, 23 Sep 2015 00:21:22 +0200, Laura Creighton 
> declaimed the following:
>
>
>>
>>You need to convert your results into a string first.
>>
>>result_int=1234523
>>result_list=[]
>>
>>for digit in str(result_int):   
>>result_list.append(int(digit))
>>
>
>   Rather wordy... 
>
 [int(i) for i in str(1234523)]
> [1, 2, 3, 4, 5, 2, 3]

I'm suprised. Why not just:

list(str(results))

In other words, is there something else the list constructor should do
with a string other than convert it to a list?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: should self be changed?

2015-05-28 Thread Anssi Saari
Marko Rauhamaa ma...@pacujo.net writes:

 Ned Batchelder n...@nedbatchelder.com:

 I would find it much clearer to not use a nested class at all, and
 instead to pass the object into the constructor:

 Nested classes are excellent and expressing the state pattern URL:
 http://en.wikipedia.org/wiki/State_pattern.

Do you have an example of state pattern using nested classes and python?
With a quick look I didn't happen to find one in any language.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Running cool and silent

2015-05-19 Thread Anssi Saari
Rustom Mody rustompm...@gmail.com writes:

 Does someone know what it does? [Dont remember where I found it]

One more comment: run Intel's Powertop to see what else you can do to
improve power management on your laptop.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Running cool and silent

2015-05-19 Thread Anssi Saari
Rustom Mody rustompm...@gmail.com writes:

 For some reason my Dell laptop runs hot and noisy in linux but cool and
 silent in Windows-8

 Running

 $ echo min_power | sudo tee 
 /sys/class/scsi_host/host*/link_power_management_policy

 makes the fan slow/stop.

 But I am not sure what it does!!
 [I dont want my laptop fried and its rather HOT out here right now :-) ]

That just turns on the power management on your SATA links. Goggle SATA
ALPM if you like. It's perfectly safe.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pymongo and attribute dictionaries

2015-02-05 Thread Anssi Saari
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes:

 Vito De Tullio wrote:

 Steven D'Aprano wrote:
 
 This just does not roll of the fingers well. Too many “reach for
 modifier keys” in a row.
 
 *One* modifier key in a row is too many?
 
 s o m e SHIFT D o c [ ' SHIFT _ i d ' ]
 
 I'm not OP, but as side note... not everyone has [ as a direct character
 on the keyboard. I need to press AltGr + è (and AltGr + + to get
 ]), so I can feel the OP lamenting :)

 Point taken. Thank you.

What I find surprising is that so many people cling so hard to their
localized keyboard layouts. I think none of those were created by
engineers and should be avoided by technical people. Or, in fact,
everyone. Even Microsoft seems to understand this and so Windows
installs the US English layout by default as an alternative.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ghost vulnerability

2015-02-03 Thread Anssi Saari
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes:

 Here's the one-liner:

 python -c 'import socket;y=0*5000;socket.gethostbyname(y)'


 I think it is likely that y=0*5000 would segfault due to lack of
 memory on many machines. I wouldn't trust this as a test.

Hmm, how much RAM does that one-liner actually need? My router has 128 
MB total RAM with about 90 MB free. So it can store the string once but
if it's copied with the gethostbyname call then it'll run out...

According to a Reddit thread
(http://www.reddit.com/r/Python/comments/2u7ghu/python_socketgethostbyname_is_not_affected_by/)
Python's socket.gethostbyname() doesn't actually even call the
gethostbyname function in glibc, it uses the newer getaddrinfo instead.
So it's a little unlikely to cause a segfault because of the Ghost vuln :)

Anyways, here's an example calling gethostbyname directly in python:

from ctypes import CDLL
o = CDLL('libc.so.6')
for i in range(0, 2500):
o.gethostbyname('0'*i)

I don't have a vulnerable system to test on any more though.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ghost vulnerability

2015-02-03 Thread Anssi Saari
Rustom Mody rustompm...@gmail.com writes:

 How many people (actually machines) out here are vulnerable?

 http://security.stackexchange.com/questions/80210/ghost-bug-is-there-a-simple-way-to-test-if-my-system-is-secure

 shows a python 1-liner to check

Does that check actually work for anyone? That code didn't segfalt on my
vulnerable Debian system but it did on my router which isn't (since the
router doesn't use glibc). Oh and of course I can't comment on
stinkexchange since I don't have whatever mana points they require...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Future of python on android

2014-12-29 Thread Anssi Saari
Fetchinson . fetchin...@googlemail.com writes:

 So what's the future proof way of writing/deploying/installing python
 programs on android?

Kivy is it I believe. I've meant to look into it but haven't gotten
around to it...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating interactive command-line Python app?

2014-12-18 Thread Anssi Saari
rfreundlic...@colonial.net writes:

 um, what if I want to USE a command line for python WITHOUT downloading or 
 installing it

Then click on the little _ icon on the web site and you have a python
prompt in your browser.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do you like the current design of python.org?

2014-12-09 Thread Anssi Saari
Rustom Mody rustompm...@gmail.com writes:

 Pretty... but not exactly what I expect in an interactive console.

I have to agree although the console works for me. But shame on the site
maintainers though, the interactive console comes up with Python 3.3.6
instead of current 3.4.2 (and IPython 2.10, also not the latest).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Matplotlib Contour Plots

2014-08-18 Thread Anssi Saari
Jamie Mitchell jamiemitchell1...@gmail.com writes:

 I created the 2D array which read as:

Maybe you could try numpy.reshape() on your 1D array?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unable to run print('Réussi') on windows and on linux

2014-08-14 Thread Anssi Saari
marc.vanhoomis...@gmail.com writes:

 What should i do to let the same program run on both OS, without changes?

You'd want to set the locale on your Ubuntu box to a UTF8 locale. On
the command line you'd run sudo dpkg-reconfigure locales and proceed
from there, but I guess there might be gooey way to do that too.

But really, it's a Linux configuration question, not a Python question.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to write file into my android phone?

2014-08-12 Thread Anssi Saari
Chris “Kwpolska” Warrick kwpol...@gmail.com writes:

 2) the phone isn't necessarily visible on a pc as a drive at all.
  For example the Samsung gs4.

 This is actually true for ALL android devices, starting with Android 3.0.

There was just a guy on comp.mobile.android saying his Android 4.2 phone
(BLU Dash or something like that, extremely Chinese) presents its
external SD card as a USB Mass Storage drive to a PC when connected over
USB. Exactly the thing Google hates and fears and has tried to kill
off... But it's not like Google can force anything on phones running
AOSP Android without Google services and that's China and a few other
large emerging markets. So it's just our small market here in the
western countries where Google has some control...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: usenet reader software

2014-07-22 Thread Anssi Saari
memilanuk memila...@gmail.com writes:

 I'm on Ubuntu (14.04 LTS, if it matters) and I've been using
 Thunderbird for a lng time... I've tinkered with slrn off and on
 over the years, tried pan occasionally due to recommendations... but I
 keep ending up back @ Thunderbird.  About the only thing it doesn't do
 that I really want is scoring/kill-files.  

I always thought Thuderbird was a lost cause especially with News but it
has some serious issues as a mail client too. Probably part of the
reason why it never caught on and development stopped. Pretty good and
nice to have a cross platform thing but they kept it an island, unable
to sync contacts to anything else. Well, the Mac version could at least
use the Mac addressbook but on Windows and Linux it's just WTF.

 Slrn has those, and I do use vim on occasion so that worked well
 enough... but when people *do* post links or html it didn't handle
 that stuff gracefully like Thunderbird.

I don't really know about about html and slrn since I don't see much of
it but links in a terminal application is usually something for the
terminal to handle. I run Gnus on a remote machine and use a local
terminal for display, Konsole in Linux and mintty in Windows. In both of
those terminals URLs are opened with a right click on the link and
selecting open link from the menu that pops up.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: usenet reader software

2014-07-22 Thread Anssi Saari
Marko Rauhamaa ma...@pacujo.net writes:

 Martin S shieldf...@gmail.com:

 Is there a point to still use Usenet? Last time I checked noise
 overwhelmed signal by a factor of something close to 542.

 Well, here you are at URL: news:comp.lang.python, in the middle of all
 that noise.

Besides, there's been a slight resurgence in comp.misc at least,
apparently some people got angry about something at slashdot and wanted
a more free forum, hence a bunch of posts there and some other groups
recently.

Other than that, I think most of the angry people and spammers have left
Usenet alone. All the better for those of us who stick with it but I
have to say the average age of people posting to comp.arch at least is
probably over 60... The only younger people around seem to be the kids
asking for people to do their homework.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: open() and EOFError

2014-07-10 Thread Anssi Saari
Roy Smith r...@panix.com writes:

 I once knew a guy who linked /dev/tty.c to /dev/tty, then he could do 
 cc /dev/tty.c and type a C program in to the compiler from the 
 terminal.

I thought some old C compilers took input from stdin without that kind
of trickery? Oh, looks like modern gcc does it too, as long as the
language is specified with -x.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to write this repeat matching?

2014-07-07 Thread Anssi Saari
rxjw...@gmail.com writes:

 Because I am new to Python, I may not describe the question clearly. Could you
 read the original problem on web:

 https://docs.python.org/2/howto/regex.html

 It says that it gets 'abcb'. Could you explain it to me? Thanks again

Actually, it tries to explain how * works in the regular expression
engine. Do you feel that's a crucial thing for a beginner to understand
about Python? Hopefully your answer is no and you can move on.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: DHCP query script not work.

2014-06-19 Thread Anssi Saari
不坏阿峰 onlydeb...@gmail.com writes:

 Dear all

 i got code recipes from here. and i want to run it on win 7. 
 http://code.activestate.com/recipes/577649-dhcp-query/

It works for me as is in Windows 7. It's a Python 3 script though which
might be your problem.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-16 Thread Anssi Saari
Gregory Ewing greg.ew...@canterbury.ac.nz writes:

 Current draw of CMOS circuitry is pretty much zero when
 nothing is changing, so if you didn't care how slow it ran,
 you probably could run a server off a watch battery today.

That was before 90 nm when leakage current started dominating over
switching current. But has low power or battery life been in anyone's
interest ever?  Or rather, is battery life interesting enough that
marketing would notice? Or maybe it's so that what a marketing guy or a
manager needs is maybe one hour for his presentation so anything over
that is extra?

A few years ago jumbo sized but cheapish CULV laptops suddenly had 10
hours plus battery but did anyone notice or care? Today expensive
Haswell ULT laptops get the same while being relatively thin and light
but again, where's the interest? Apple didn't even bother trying to make
improved battery life a selling point for the 2013 Macbook Air. I was
seriously considering one but I prefer matte displays and cellular
connectivity built in.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Micro Python -- a lean and efficient implementation of Python 3

2014-06-06 Thread Anssi Saari
Chris Angelico ros...@gmail.com writes:
 
 I don't have an actual use-case for this, as I don't target
 microcontrollers, but I'm curious: What parts of Py3 syntax aren't
 supported?

I meant to say % formatting for strings but that's apparently been added
recently. My previous micropython build was from February.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: passing an option to the python interpreter

2014-03-02 Thread Anssi Saari
Marko Rauhamaa ma...@pacujo.net writes:

 Jabba Laci jabba.l...@gmail.com:

 I tried this:

 #!/usr/bin/env python -u

 The hash-bang notation is quite rigid; it only accepts a single argument
 (python) to the command (/usr/bin/env).

 I don't know if there is a simple workaround.

Using the relevant environment variable (PYTHONUNBUFFERED) seems simple
to me.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to install automatically missing modules on a debian-system

2014-02-28 Thread Anssi Saari
hugocoolens hugocool...@gmail.com writes:

 It often happens I start a python-script I wrote some time ago on another
 system and get messages like module_x is missing. I then perform an 
 apt-cache search module_x, followed by an apt-get install 
 name_of_missing_module.deb
 I was wondering whether someone here has a kind of method which automatically
 looks for the missing modules as debian-packages and offers to install them?

I don't know if there's anything that works with random Python scripts.
I suppose the straightforward Debian way of it would be to package your
script in a .deb package and include the proper dependencies, then apt
would take care of installing those too.

Debian has a wiki page covering the project's Python packaging policy
and how to do it at https://wiki.debian.org/Python/Packaging.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: extend methods of decimal module

2014-02-28 Thread Anssi Saari
Terry Reedy tjre...@udel.edu writes:

 On 2/27/2014 7:07 AM, Mark H. Harris wrote:

 Oh, and one more thing... whoever is doing the work on IDLE these
 days, nice job!   It is stable, reliable, and just works/
 appreciate it!

 As one of 'them', thank you for the feedback. There are still some
 bugs, but I hit them seldom enough that I am now looking at
 enhancement issues.

I recently watched a presentation by Jessica McKellar of PSF about what
Python needs to stay popular. Other than the obvious bits (difficulties
or limited support of Python on major platforms like Windows and mobile)
the slight lack of perfection in IDLE was mentioned. Specifically the
old blog post titled The Things I Hate About IDLE That I Wish Someone
Would Fix at
http://inventwithpython.com/blog/2011/11/29/the-things-i-hate-about-idle-that-i-wish-someone-would-fix/

It lists 17 issues and some more in the comments. Are those things
something that could be considered? Or have maybe been done already? I'm
not an IDLE user so this is mostly an academic interest on my part.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What are the kinds of software that are not advisable to be developed using Python?

2014-02-10 Thread Anssi Saari
Asaf Las roeg...@gmail.com writes:

 btw, Python could be language of choice for embedded systems if small 
 footprint 
 vm could be developed. had seen similar for java having 10-20 KB byte sized 
 interpreter with very limited set of functions.

Well, there's the newish Micro python project. Its footprint is
apparently about 60 kB at a minimum (Thumb2 code on ARM). Their
kickstarter is at
https://www.kickstarter.com/projects/214379695/micro-python-python-for-microcontrollers
and source at https://github.com/micropython/micropython

The kickstarter was for funding development and a small board with ST's
Cortex-M4 on it. The source code includes Windows and Unix targets so
it's easy to experiment with without a board too.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Copy a file like unix cp -a --reflink

2013-12-20 Thread Anssi Saari
Paulo da Silva p_s_d_a_s_i_l_...@netcabo.pt writes:

 Hi!

 Is there a way to copy a file the same as Unix command:

 cp -a --reflink src dest

 without invoking a shell command?

I vaguely remember this was asked and answered some time ago and the
answer was no, even just for -a.  In fact, the python shutil module
documentation starts with a warning to that effect. The --reflink stuff
would be another thing altogether.

More accurately, currently the only way would be to duplicate this
functionality of cp in python.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie - Trying to Help a Friend

2013-11-21 Thread Anssi Saari
Dennis Lee Bieber wlfr...@ix.netcom.com writes:

   Does Pan have an option to generate its own Message-ID header?

   Headers seem to indicate multiple injections somewhere

Perhaps Pan doesn't? Someone else had multipostings in the Android group
but he was posting via aioe.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Changing the terminal title bar with Python

2013-10-23 Thread Anssi Saari
dic...@his.com writes:

 On Friday, October 18, 2013 12:46:19 PM UTC-4, Steven D'Aprano wrote:

 xterms used to have a feature where they would write the title back to 
 standard input. Unfortunately, it has been disabled for security reasons, 
 so I haven't been able to get this to work (not that I tried very 
 hard...), but you might like to experiment with this:

 Actually in xterm it is configurable (the allowWindowOps resource).
 xterm emulators lack that (and most of xterm's) configurability.

Curious. I was able to do the title store and restore after allowing
WindowOps in xterm version 278 (from the ctrl-rightclick menu) but
reading the title didn't work any better.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is %z broken for return values of time.gmtime()?

2013-09-19 Thread Anssi Saari
random...@fastmail.us writes:

 I would argue that it _should_ be, and that it should populate it with 0
 in gmtime or either with timezone/altzone or by some sort of reverse
 calculation in localtime, but it is not. Another problem to add to my
 list of reasons for my recent python-ideas proposal.

Docs say that tm_gmtoff and tm_zone are available if the struct tm in
the underlying C library has it. Based on that I kinda expected Cygwin
to have it but apparently not.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: HID Feature Raport, Linux

2013-09-18 Thread Anssi Saari
Kasper Jepsen rap...@gmail.com writes:

 Hi,

 I have been using pywinusb.hid for a hid unit, using only feature reports.
 I like to get this code to run on raspbian PI, but i can not fint a good 
 library to support HID/feature reports?
 I am a USB newbie 
 Can anyone help me, or point me in a direction to send/recieve feature 
 reports without HID support?

I believe pyusb with libusb or libusbx would work. There's a summary of
the alternatives at
http://mcuee.blogspot.fi/2011/04/python-and-usb-hid-device.html if that
helps.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: My son wants me to teach him Python

2013-06-14 Thread Anssi Saari
Chris Angelico ros...@gmail.com writes:

 I have tab completion. Beat that, GUI.

Decent GUIs *have* tab completion. Bad GUIs don't.

Oh wait. Is a GUI with tab completion a GUI at all or more of a weird
ass hybrid? What about a CLI that pops up a menu for completions?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Version Control Software

2013-06-14 Thread Anssi Saari
cutems93 ms2...@cornell.edu writes:

 Thank you everyone for such helpful responses! Actually, I have one more 
 question. Does anybody have experience with closed source version control 
 software? If so, why did you buy it instead of downloading open source 
 software? Does closed source vcs have some benefits over open source in some 
 part? 

I have some experience with ClearCase. I don't know why anyone would buy
it since it's bloated and slow and hard to use and likes to take over
your computer. I was very happy to dump it when my team was allowed to
use whatever we wanted but then we were not doing software either.

ClearCase is also admin heavy for the above reasons. I guess big
businesses buy things like that because other big businesses buy things
like that. Presumably they keep it because it's cheaper to pay
maintenance than move all source to some other system.

Now granted, Linux development went to commercial Bitkeeper for a while
since Linus Torvalds found it superior to CVS sometime over a decade
ago. When the agreement ended, Torvalds himself developed Git to be what
he needs. Other projects sprang up around the same time to get that job,
this means at least Mercurial if Wikipedia is to be believed.

Oh, as far as I know, commercial software vendors always ban their
customers from publishing any kinds of benchmarks or other comparisons
so it's unlikely you can find anything concrete for your commercial
vs. free choice.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner question

2013-06-04 Thread Anssi Saari
eschneide...@comcast.net writes:

 Is there a more efficient way of doing this? Any help is gratly appreciated.

Efficiency in a short program isn't a big thing. You have some pretty
weird things in there, there's no need make single element tuples out of
your strings and then putting those in a list. Just put the strings in a
tuple and go. Likewise there's really no point in having while loops
where you exit on the first round now is there? Just use an if.

BTW, did I get the logic correctly, the end result is random? If true
then the logic can be simplified greatly, you can just discard the user
input and print a random choice of your three result strings...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Apache and suexec issue that wont let me run my python script

2013-06-03 Thread Anssi Saari
Νικόλαος Κούρας nikos.gr...@gmail.com writes:

 [code]
 root@nikos [/home/nikos/www/cgi-bin]# chmod g+w /var/log/httpd/suexec.log
 root@nikos [/home/nikos/www/cgi-bin]# ls -l /var/log/httpd/suexec.log
 -rw-rw-r-- 1 root root 0 Jun 1 02:52 /var/log/httpd/suexec.log
 [/code]


 and still iam receiving the same error.

What did you hope to accomplish with this second chmod? Nobody is in the
root group except root. I hope. My guess based on very minimal Googling
on the topic is you should change the group of /var/log/httpd/suexec.log
to apache. 

Then again, I have no idea why you have both
/usr/local/apache/logs/suexec_log and /var/log/httpd/suexec.log, but the
former apparently has some data in it and the latter does not so
changing permissions on /var/log/httpd/suexec.log may not help...

Oh, apparently suexec prints its config if you run suexec -V, so include
that output if you still have problems.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Source code as text/plain

2013-05-28 Thread Anssi Saari
Carlos Nepomuceno carlosnepomuc...@outlook.com writes:

 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 taken to a Mercurial page:

 http://hg.python.org/cpython/file/2.7/Lib/string.py

 but over there there's no way to get a clean text/plain version of the code 
 because the line numbers are included.

 A link to the text/plain version on that page would be nice!  
   

The 'raw' link on the left spews the source as application/binary so
most likely your browser will download it instead of showing it. Which
is what you asked but if you wanted to view in browser sans the line
numbers, there doesn't seem to be a way.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Append to python List

2013-05-11 Thread Anssi Saari
Chris Angelico ros...@gmail.com writes:

 On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen
 jpiit...@ling.helsinki.fi wrote:
 8 Dihedral writes:

 This is just the handy style for a non-critical loop.
 In a critical loop, the number of  the total operation counts
 does matter in the execution speed.

 Do you use speed often?

 Dihedral is a bot. Quite a good one, but a bot.

That's been said often enough. Is the source available and is it in
Python?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cross-compiling Python for ARM?

2013-04-16 Thread Anssi Saari
Gilles nos...@nospam.com writes:

 I see Python mentioned in /usr/lib and /usr/share, and was wondering
 if all it'd take to solve this issue, is just to cross-compile the
 interpreter and the rest is just CPU-agnostic Python scripts.

I suppose. In any case, cross compiling Python shouldn't be that hard. I
just recently built 2.7.3 for my OpenWRT router since the packaged
Python didn't have readline support (some long standing linking issue
with readline and ncurses and uClibc).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with zip in a Python exercise

2013-03-28 Thread Anssi Saari
lug...@elpasotel.net writes:

 I've been working through a Python tutorial online and one of the exercises 
 uses the zip command.  The only problem is that the command doesn't work.  
 I've read through the man page for zip and it looks like what I'm attempting 
 should work, but it doesn't.

 The command is:

 zip -qr /media/backup/backups/test/20130326100218.zip -i 
 /home/luggw1/Documents/ /home/luggw1/Code/

-i simply isn't used to to specify which directories you want to
 zip. You can use it to specify filenames that you want in your zip,
 regardless of where they are. Not exactly an option I've ever had use
 for in over a decade of using zip...

Just leave -i out of the command and you'll probably get what you
intended.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Shebang line on Windows?

2013-02-26 Thread Anssi Saari
Michael Torrie torr...@gmail.com writes:

 Actually, the shell isn't involved in parsing the shebang line at all.
 That's actually done in the kernel by the program loader.  So it's the
 kernel that has a problem with it; wonder if Linus would accept a patch
 to ignore the tailing CR?

Worth a try in my opinion. There's some historical information about the
shebang at http://www.in-ulm.de/~mascheck/various/shebang/ There's a
table which says Linux since 2.4.0 removes trailing whitespace from the
shebang line. I guess Linux doesn't count CR as whitespace in this
context.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: nested loops

2013-02-26 Thread Anssi Saari
leonardo tampucciol...@libero.it writes:

 how can i have it print  a row of stars beside each number, like this?:

 how many seconds?: 5
 5 * * * * *
 4 * * * *
 3 * * *
 2 * *
 1 *
 blast off!

You could use the repetition operator * since you have the number of
repetitions needed in i. Alternatively, considering the subject, you'd
just add another for loop to print the stars and spaces.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.3 vs. MSDOS Basic

2013-02-19 Thread Anssi Saari
John Immarino joh...@gmail.com writes:

 I coded a Python solution for Problem #14 on the Project Euler
 website. I was very surprised to find that it took 107 sec. to run
 even though it's a pretty simple program.  I also coded an equivalent
 solution for the problem in the old MSDOS basic. (That's the 16 bit
 app of 1980s vintage.)

Just out of curiosity, can you post the basic version as well?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Opinion on best practice...

2013-02-06 Thread Anssi Saari
Dennis Lee Bieber wlfr...@ix.netcom.com writes:

   PowerShell is meant to be used for administrative level scripting,
 replacing such things as WSH.

Yeah and WSH has been included since Windows 98... So Windows has been
at least OK with shell scripting VBScript and JScript for the last 15
years or so. And I can't believe I'm defending Windoze.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New to python, do I need an IDE or is vim still good enough?

2013-01-04 Thread Anssi Saari
Ben Finney ben+pyt...@benfinney.id.au writes:

 Hans Mulder han...@xs4all.nl writes:

 Don't bother: Python comes with a free IDE named IDLE.

 And any decent Unix-alike (most OSen apart from Windows) comes with its
 own IDE: the shell, a good text editor (Vim or Emacs being the primary
 candidates), and a terminal multiplexor (such as ‘tmux’ or GNU Screen).

Just curious since I read the same thing in a programming book recently
(21st century C). So what's the greatness that terminal multiplexors
offer over tabbed terminals? Especially for software development?

For sure I use screen at the remote end of ssh connections where I don't
want the application like irssi to die if the connection goes down but
other than that?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Numpy module

2012-11-08 Thread Anssi Saari
farrellpolym...@gmail.com writes:

 Hello to the group!

 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 same directory, like 'email' and it imports fine.

 Does Numpy 1.6.2 not run with Python 3.2.3?

 Can anybody help? Thank you in advance.

What's the goal of this exercise? Ubuntu packages Python 3 and Numpy so
all you need to do is install packages python3 and python3-numpy. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fwd: system tray or notification area in python

2012-10-19 Thread Anssi Saari
Daniel Fetchinson fetchin...@googlemail.com writes:

 But I have zero experience with gui programming in python. So any
 pointers would be much appreciated how to implement a system tray in
 python. Gtk is I guess just one option, one could use other stuff from
 python but I wouldn't know what the simplest approach is.

Well, when I went to download stalonepanel, SourceForge said I might be
interested in PyPanel as well. Which is a lightweight panel/taskbar
written in Python and C for X11 window managers. It includes a system
tray. Fairly old though but I suppose it could be a start? Apparently it
uses python-xlib.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python 6 compilation failure on RHEL

2012-08-25 Thread Anssi Saari
Cameron Simpson c...@zip.com.au writes:

 My personal habit to to build with (adjust to match):

   --prefix=/usr/local/python-2.6.4

 and put some symlinks in /usr/local/bin afterwards (python2.6, etc).

There's actually a program for that, it's called stow.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-11 Thread Anssi Saari
Wolfgang Keller felip...@gmx.net writes:

 This whole cycle of design GUI-generate code-add own code to
 generated code-run application with GUI has always seemed very
 un-pythonic to me. A dynamic, interpreted language should allow to work
 in a more lively, direct way to build a GUI.

What about Qt Quick? I have used it very little, but it does allow
dynamic modification of the GUI elements so that the application
changes on the fly. I don't know how pythonic it is, since the GUI is
described in QML, which combines CSS and javascript.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Threads on google groups not on gmane?

2012-04-01 Thread Anssi Saari
Mark Lawrence breamore...@yahoo.co.uk writes:

 I went onto google groups to do a search and saw three threads (there
 may be more) that I've never seen on gmane, which I read via
 thunderbird on windows.  The titles are Is programming art or
 science, breezypythongui: A New Toolkit for Easy GUIs in Python and
 weird behaviour: pygame plays in shell but not in script.

 Is anyone else seeing the same thing?

I've noticed a lot of messed up threads but that's apparently considered
normal here. But I also see broken threads where only some messages are
visible on, so it's not a huge stretch that some threads might be
completely invisible to me.

I read through a normal NNTP server.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python usage numbers

2012-02-15 Thread Anssi Saari
Matej Cepl mc...@redhat.com writes:

 Slightly less flameish answer to the question “What should I do,
 really?” is a tough one: all these suggested answers are bad because
 they don’t deal with the fact, that your input data are obviously
 broken. The rest is just pure GIGO … 

Well, sure, but it happens that input data is broken and not fixable.
For example, I did a little program to display email headers like the
old frm that was bundled with elm, only with support for MIME decoding
of the headers. Obviously lots of email software is still completely
broken regarding MIME and also multi-line headers. However, something
useful can still be extracted from that broken data.

 BTW, can you display the following line?

 Příliš žluťoučký kůň úpěl ďábelské ódy.

Looks fine to me. You used an ellipsis too above. Well, I don't know
what it shold look like exactly. Lots of accents. Hmm, Google says it
means The quick brown fox cried too lazy? Seems appropriate :) BTW, I'm
sending this via Usenet, I wonder what happens in the mail-news gateway?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Determining version of OpenSSL linked against python?

2012-01-25 Thread Anssi Saari
Adam Mercer ramer...@gmail.com writes:

 Can anyone offer any suggestions as to what is going wrong with the
 above code or offer an alternative way of determining the OpenSSl
 version using python-2.6?

I suppose you could use ctypes to load the library and call SSLeay()
which returns the OpenSSL version number as a C long.

Like this:

from ctypes import *
libssl = cdll.LoadLibrary(libssl.so)
openssl_version = libssl.SSLeay()
print %.9X % openssl_version

This gives me 0009080FF which corresponds to 0.9.8o release which is
what I have installed in Debian Squeeze.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: First python project : Tuner

2012-01-20 Thread Anssi Saari
Jérôme jer...@jolimont.fr writes:

 - I tried to clarify the dependencies of my program by adding 
   PyGObject (python-gi).
   I believe PyGObject is the name, but python-gi being the name of the debian
   package (and possibly other distros' package, I didn't check), I assumed it
   would be more helpful.

You might mention that Debian Stable (Squeeze) doesn't have a new enough
PyGObject to run your code. There's no package python-gi and the version
of python-gobject is 2.21.4+is.2.21.3-1. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Installing Python on CentOS 6 - a big pain

2012-01-20 Thread Anssi Saari
Benedict Verheyen benedict.verhe...@gmail.com writes:

 If i need to install a new version of Python, as I happen to have done today,
 I only need to do step 4. Which is maybe 5 minutes of work.

I don't really understand why you compile these common libraries (zlib,
ncurses, readline) yourself instead of using the relevant libraries
provided by your Debian system? Is it just that you didn't *know* Debian
puts parts needed for compilation in separate packages so you'd need to
install those first?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with python-list archives

2012-01-10 Thread Anssi Saari
Ian Kelly ian.g.ke...@gmail.com writes:

 Probably nobody has noticed it until now.  It seems to be a quirk of
 the archive files that they are double-gzipped...

Interesting, but I don't think the files are actually double-gzipped. If
I download
http://mail.python.org/pipermail/python-list/2012-January.txt.gz with
wget in Cygwin or Unix, the file is 226753 bytes and singly gzipped.

However, if I download the same file with Firefox in Windows, then it's
226782 bytes and double gzipped. So maybe it's something in the browser
or server setup?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to install Python on Debian GNU/Linux (Python-2.7.2.tar.bz2)

2011-12-14 Thread Anssi Saari
Christian Heimes li...@cheimes.de writes:

 Mea culpa, forgot that. Yes, use altinstall. Although it's probably
 not a problem to replace 2.6.6 with 2.7.2 - I doubt that'll break many
 things.

 Except that all 3rd party extensions and packages are missing if you
 install Python manually.

True, they would have to be built or at least installed manually also.
Major work, especially for a beginner. Shouldn't pick Debian Stable and
then want current software...

Then again, even the standard install of Python has plenty of stuff. I
installed 2.7.2 on my Debian system just to try out some of the new Tk
stuff.

 Debian's backports should provide a well integrated Python 2.7
 package.

But it doesn't. Python 2.7.2 is in Wheezy, which is the current testing
version of Debian. Looks like it has about 700 release critical bugs, so
it'll be a while until release.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7.2 on Win7 and IDLE (Try it)

2011-11-23 Thread Anssi Saari
W. eWatson wolftra...@invalid.com writes:

 One thing I think no one has offered is whether their installation of
 2.7.2 has the same IDLE oddity that I've described.  That is, if you
 right-click on a py file, do you see a choice for the IDLE editor?

I don't have 2.7.2, but my Windows (7, 32 bit) machine has 3.2 installed
and also 2.6.6 included in Python(x,y) distribution.

Right clicking on a .py has, under Open with, the choices GNU
Emacsclient (my choice for editing), python.exe and pythonw.exe. No
Idle.

I was able to add idle to the menu it by clicking Choose default
program in the menu and pointing that to idle.bat.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-23 Thread Anssi Saari
goldtech goldt...@worldpost.com writes:

 Using Windows. Is there a python shell that has a history of typed in
 commands?

Is there a shell that doesn't have history then? At least both the
vanilla shell and Idle both have basic history in Windows. IPython for
more fun.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What I do and do not know about installing Python on Win 7 with regard to IDLE.

2011-11-23 Thread Anssi Saari
Dennis Lee Bieber wlfr...@ix.netcom.com writes:

 c:\Python32 Start in, and for Target: Python 3.2.2 (64-bit)

   Which tells me that the TARGET field is garbaged, since THAT is what
 specifies the program (and arguments) that has to be run when the
 shortcut is double-clicked.

Actually, no, it's what I have too. 32-bit Windows 7 here and Python
3.2. The Target for the Idle shortcut is just Python 3.2. It's also
greyed out and uneditable.

So yes, weird. Mine works though and I rarely use Idle, so no
complaints.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is wrong with my code?

2011-10-25 Thread Anssi Saari
apometron apometron.listas.ci...@gmail.com writes:

 Now it is another
 thing, entirely. Rename1.py and Rename2.py works, but why Rename3.py
 dont works?

Well, Rename3.py works for me, even in Windows 7. Maybe you should test
it again?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: callling python function in c

2011-10-18 Thread Anssi Saari
masood shaik masood@gmail.com writes:

 Hi

   I am trying to call python function from c code.The following
 program i got from the web source while i am trying to run this
 program it throws an segmentation fault.

Yes, the call to PyImport_Import fails and returns a NULL. You could use
the more complete example at
http://docs.python.org/extending/embedding.html which includes some
error handling...

Anyways, apparently PyImport_Import can't import from the current
working directory but with parameters like math sqrt 2 it returns the
square root of 2. Setting PYTHONPATH to point to the working directory
works for me, but I don't know if there's a more correct solution.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: strange results

2011-09-17 Thread Anssi Saari
Fig brandonfig...@gmail.com writes:

 My OS is Windows 7, Python 2.7.2, I downloaded and installed the
 python-gasp-0.2.0beta1.win32.exe file, and I also have these
 installed: Python 2.7 pygame-1.9.2a0 and Python 2.7 pywin32-216

Then maybe that old beta version is your problem? For the record, your
code works for me too in Linux and python-gasp 0.3.3. 

Looks like there's no Windows installer for newer python-gasp. Maybe you
could install with easy_install as they describe on the site?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: idiomatic analogue of Perl's: while () { ... }

2011-09-01 Thread Anssi Saari
Sahil Tandon sa...@freebsd.org writes:

 I've been tasked with converting some programs from Perl - Python, and
 am (as will soon be obvious) new to the language. 

If it's any help, I have usually done handling of standard input line by
line with this kind of thing:

for inputline in sys.stdin:
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: locale.format without trailing zeros

2011-08-22 Thread Anssi Saari
przemol...@poczta.fm writes:

 Hello,

 import locale
 locale.setlocale(locale.LC_ALL, pl_PL)
 'pl_PL'
 i=0.20
 j=0.25
 locale.format('%f', i)
 '0,20'
 locale.format('%f', j)
 '0,25'

 I need to print the numbers in the following format:
 '0,2' (i)
 '0,25'(j)
 So the last trailing zeros are not printed.

That would be the %g conversion specifier.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: List spam

2011-08-18 Thread Anssi Saari
Ghodmode ghodm...@ghodmode.com writes:

 Newsgroups aren't inherently spam-free.  They're filtered.  At least
 that's the case with Gmane (http://gmane.org/spam.php).

 My own ISP doesn't provide a news server and, although there are many
 links for free open news servers, most of them don't seem to work.

You know, Gmane allows access also via NNTP, including this list.
Server news.gmane.org, group name gmane.comp.python.general.

Haven't used it since I get this list via normal NNTP as
comp.lang.python. My NNTP access is via a computer club for 8 euros
per year.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-18 Thread Anssi Saari
Thorsten Kampe thors...@thorstenkampe.de writes:

 The perfect programming font is just the one that looks so good that 
 you would also use it for writing email. Dejavu Sans Mono is pretty 
 good. Consolas looks also looks good but it is Windows only.

How is Consolas Windows only? Not that I'd put it in my Windows-free
systems, but I don't see why you couldn't? Everything uses TrueType
fonts now.

I use a font called Dina on this laptop in Emacs. Not pretty but very
readable, has a slashed zero and the wide characters are clearly
separated, so something like www looks like three ws, not a block of
triangle wave.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does hashlib support a file mode?

2011-07-07 Thread Anssi Saari
Mel mwil...@the-wire.com writes:

 def file_to_hash(path, m = hashlib.md5()):

 hashlib.md5 *is* called once; that is when the def statement is executed.

Very interesting, I certainly wasn't clear on this. So after that def,
the created hashlib object is in the module's scope and can be
accessed via file_to_hash.__defaults__[0].
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >