Re: install open cv on windows 10 and python 3.5

2016-04-02 Thread Xristos Xristoou
Τη Παρασκευή, 1 Απριλίου 2016 - 1:56:52 μ.μ. UTC+3, ο χρήστης Xristos Xristoou 
έγραψε:
> hello,
> 
> i have windows 10 and python 3.5 and i want to use
> open cv but i think so opencv work only on python 2.7 ?
> and i install this http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv
> but not work again

yes i cant import cv2 on my idle that is my problem
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: extract rar

2016-04-02 Thread DFS

On 4/1/2016 5:01 PM, Jianling Fan wrote:

Thanks, but the problem is that I am not allowed to install any
software in my office PC, even free software.
Normally, I use zip files but this time I need to extract a rar file.
I don't like to go to IT guys because it takes time.
That's why I am looking for an alternative way without installing
other software.

  Thanks,

On 1 April 2016 at 13:37, Albert-Jan Roskam  wrote:





Date: Fri, 1 Apr 2016 13:22:12 -0600
Subject: extract rar
From: [email protected]
To: [email protected]

Hello everyone,

I am wondering is there any way to extract rar files by python without
WinRAR software?

I tried Archive() and patool, but seems they required the WinRAR software.


Perhaps 7-zip in a Python subprocess:
http://superuser.com/questions/458643/unzip-rar-from-command-line-with-7-zip/464128



I'm not experienced with Python, but I found this:

"pip install patool
import patoolib
patoolib.extract_archive("foo_bar.rar", outdir=".")
Works on Windows and linux without any other libraries needed."

http://stackoverflow.com/questions/17614467/how-can-unrar-a-file-with-python


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


Re: [beginner] What's wrong?

2016-04-02 Thread Chris Angelico
On Sat, Apr 2, 2016 at 3:27 PM, Random832  wrote:
> On Fri, Apr 1, 2016, at 19:29, Michael Selik wrote:
>> Humans have always had trouble with this, in many contexts. I remember
>> being annoyed at folks saying the year 2000 was the first year of the new
>> millennium, rather than 2001. They'd forgotten the Gregorian calendar
>> starts from AD 1.
>
> Naturally, this means the first millennium was only 999 years long, and
> all subsequent millennia were 1000 years long. (Whereas "millennium" is
> defined as the set of all years of a given era for a given integer k
> where y // 1000 == k. How else would you define it?)
>
> And if you want to get technical, the gregorian calendar starts from
> some year no earlier than 1582, depending on the country. The year
> numbering system has little to do with the calendar type - your
> assertion in fact regards the BC/AD year numbering system, which was
> invented by Bede.
>
> The astronomical year-numbering system, which does contain a year zero
> (and uses negative numbers rather than a reverse-numbered "BC" era), and
> is incidentally used by ISO 8601, was invented by Jacques Cassini in the
> 17th century.
>

Are you sure? Because I'm pretty sure these folks were already talking about BC.

http://xenohistorian.faithweb.com/holybook/quotes/YK.html

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


Re: Grab metadata from images and save to file, batch mode

2016-04-02 Thread Vincent Vande Vyvre

Le 01/04/2016 23:20, [email protected] a écrit :

I have a directory (and sub-directories) full of images that I want to cycle 
through and grab certain metadata values and save those values to a single row 
in a cvs file. I would like to tack on the full path name to the row as a 
separate value.

Folder
C:\Images\Family
Brother.jpg
Sister.jpg
Mom.jpg

Keys/Values
Original Date/Time
User Name
File Name

Thus, data might look like this in a Family.csv file
2014:11:10 13:52:12; BillyBob111; Brother.jpg; C:\Images\Family\Brother.jpg
2015:10:54 11:45:34; BillyBob111; Sister.jpg; C:\Images\Family\Sister.jpg
2010:10:31 19:22:11; SallySue232; Mom.jpg; C:\Images\Family\Mom.jpg

Big time noob. Much of what I have read cites command line examples dealing 
with single files and no info as to how to extract specific keys and their 
values.
What module would some of you users recommend I use (I want it to be python as 
that is what I am trying to learn)

Can you give me some coding suggestions to get me goings? I haven't found any 
substantive scripts to use as guides.

Many thanks in advance



Have a look at py3exiv2:

http://python3-exiv2.readthedocs.org/en/latest/

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


Re: Strange range

2016-04-02 Thread Steven D'Aprano
On Sat, 2 Apr 2016 07:14 am, Marko Rauhamaa wrote:

> There's a bit of a cognitive dissonance between iterables and iterators.
> On the one hand, they behave identically in many contexts. On the other
> hand, the distinction is crucial in some special cases.

Iterable just means "something which can be iterated over". Anything which
you can feed directly into a for-loop:

for x in obj: ...

is by definition an iterable. The particular mechanism by which iteration is
performed is unspecified.

In Python today, there are two specific mechanisms, although in practice
only one commonly is used. The older of the two is the "Sequence Protocol",
which says that iteration is performed by repeatedly fetching an item from
the object with an incrementing index until IndexError is raised:

x = obj[0]
x = obj[1]
x = obj[2]
...


The newer, and more common, mechanism is to call iter(obj) to get an
iterator, then repeatedly call next(iterator) until it raises
StopIteration.

it = iter(obj)
x = next(it)
x = next(it)
x = next(it)
...


So what's an iterator? Any object which obeys the "Iterator Protocol". The
rules for the protocol are:

- the object must provide two methods, __iter__ and __next__;

- __iter__ must return self;

- __next__ must return the next value in the sequence, 
  or raise StopIteration.


range objects themselves do not obey the iterator protocol, which makes them
not iterators:

py> o = range(23)
py> iter(o) is o
False
py> hasattr(o, '__next__')
False


But they are *iterable* since you can call iter on a range object and get an
iterator:

py> it = iter(o)
py> iter(it) is it
True
py> hasattr(it, '__next__')
True



> (Somehow, the difference between iterables and iterators is analogous
> with the difference between C's arrays and pointers.)

I don't understand this analogy. Can you explain please?


-- 
Steven

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


Re: Drowning in a teacup?

2016-04-02 Thread Peter Otten
Vito De Tullio wrote:

> Michael Selik wrote:
> 
>>> > I need to scan a list of strings. If one of the elements matches the
>>> > beginning of a search keyword, that element needs to snap to the front
>>> > of the list.
>>>
>>> I know this post regards the function passing, but, on you specific
>>> problem,
>>> can't you just ... sort the list with a custom key?
>>
>> If the number of matches is small relative to the size of the list, I'd
>> expect the sort would be slower than most of the other suggestions.
> 
> umm... I take the liberty to set up a little test
> 
> $ cat test_sort_prefix.py
> #!/usr/bin/env python3
> 
> from sys import argv
> from timeit import timeit
> 
> 
> def sort_in_place(l):
> def key(e):
> return not e.startswith('yes')
> l.sort(key=key)
> 
> 
> def original_solution(mylist):
> for i in range(len(mylist)):
> if(mylist[i].startswith('yes')):
> mylist[:] = [mylist[i]] + mylist[:i] + mylist[i+1:]

original_solution() reverses the order of the matches while sort_in_place() 
doesn't. If the order is not relevant I'd try something like

def exchange(items):
pos = 0
for index, item in enumerate(items):
if item.startswith("yes"):
items[pos], items[index] = item, items[pos]
pos += 1

> def main():
> if argv[1] == 'sort_in_place':
> f = sort_in_place
> elif argv[1] == 'original_solution':
> f = original_solution
> else:
> raise Exception()
> 
> nomatches = int(argv[2])
> matches = int(argv[3])
> 
> l = ["no_" for _ in range(nomatches)] + ["yes_" for _ in
> range(matches)]

Python's timsort knows how to deal with (partially) sorted lists. I suggest 
that you add

random.seed(42) # same list for all script invocations
random.shuffle(l)

here to spread the matches somewhat over the list.

> print(timeit("f(l)", number=100, globals={"f": f, "l": l}))

Remember that f(l) modifies l, so all but the first invocation will see a 
list where all matches are at the beginning. In other words: in 99 out of 
100 runs the list is already sorted.

While adding the overhead of copying the list I would expect the results of

timeit("f(l[:])", ...)

to be more realistic.

> if __name__ == '__main__':
> main()
> $ ./test_sort_prefix.py sort_in_place 100 3
> 33.260575089996564
> $ ./test_sort_prefix.py original_solution 100 3
> 35.93009542999789
> $
> 
> 
> in my tests there is no sensible difference between the two solutions...
> and the number of matches is risible :)

Indeed, as the number of matches rises your sort() approach will likely fare 
better.

Your conclusions may be correct, but the benchmark to support them is 
flawed.

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


Re: Strange range

2016-04-02 Thread Marko Rauhamaa
Steven D'Aprano :

> On Sat, 2 Apr 2016 07:14 am, Marko Rauhamaa wrote:
>> (Somehow, the difference between iterables and iterators is analogous
>> with the difference between C's arrays and pointers.)
>
> I don't understand this analogy. Can you explain please?

In numerous contexts,

   T a[N]

and

   T *a

are interchangeable. In fact, C has no rvalue notation for an array. For
any other type, this works:

   T a, b;
   a = b;

However, if T is an array type, the compiler complains:

   error: assignment to expression with array type

This C innovation of blurring the lines between arrays and pointers is
very different of the type system of Pascal, whose arrays behave like
any other type.

C could have treated arrays like other types without any loss of
generality. Then you'd have to write:

   T a[N], *b;
   b = &a[0];

for:

   T a[N], *b;
   b = a;

Semantically, as well, C arrays are iterables, and pointers are used to
iterate over the elements of an array.

Similarly, Python could have kept iterables and iterators in their
separate corners by specifying:

 * iter(iterable) returns an iterator

 * iter(iterator) typically raises an Exception

 * the for statement requires an iterator

Then, you'd have to write:

   for i in iter([1, 2, 3]):
   ...


Not recommending anything one way or another.


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


Re: Drowning in a teacup?

2016-04-02 Thread Mark Lawrence via Python-list

On 02/04/2016 06:51, Michael Selik wrote:

On Sat, Apr 2, 2016, 1:46 AM Vito De Tullio  wrote:


Fillmore wrote:


I need to scan a list of strings. If one of the elements matches the
beginning of a search keyword, that element needs to snap to the front
of the list.


I know this post regards the function passing, but, on you specific
problem,
can't you just ... sort the list with a custom key?

something like (new list)

 >>> sorted(['no_a', 'yes_c', 'no_b', 'yes_z', 'no_y', 'yes_x'],
 ... key=lambda e: not e.startswith('yes'))
 ['yes_c', 'yes_z', 'yes_x', 'no_a', 'no_b', 'no_y']

or (in place)

 >>> l = ['no_a', 'yes_c', 'no_b', 'yes_z', 'no_y', 'yes_x']
 >>> l.sort(key=lambda e: not e.startswith('yes'))
 >>> l
 ['yes_c', 'yes_z', 'yes_x', 'no_a', 'no_b', 'no_y']



If the number of matches is small relative to the size of the list, I'd
expect the sort would be slower than most of the other suggestions.



My gut feeling about how fast something is in Python has never once been 
right in 15 years.  There is only way way to find out, measure it with 
things like https://docs.python.org/3/library/profile.html and 
https://docs.python.org/3/library/timeit.html.  IIRC Steven D'Aprano has 
a wrapper for the latter called Stopwatch.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Drowning in a teacup?

2016-04-02 Thread Michael Selik
On Sat, Apr 2, 2016 at 6:32 AM Peter Otten <[email protected]> wrote:

> Vito De Tullio wrote:
>
> > Michael Selik wrote:
> >
> >>> > I need to scan a list of strings. If one of the elements matches the
> >>> > beginning of a search keyword, that element needs to snap to the
> front
> >>> > of the list.
> >>>
> >>> I know this post regards the function passing, but, on you specific
> >>> problem,
> >>> can't you just ... sort the list with a custom key?
> >>
> >> If the number of matches is small relative to the size of the list, I'd
> >> expect the sort would be slower than most of the other suggestions.
> >
> > umm... I take the liberty to set up a little test
> >
> > $ cat test_sort_prefix.py
> > #!/usr/bin/env python3
> >
> > from sys import argv
> > from timeit import timeit
> >
> >
> > def sort_in_place(l):
> > def key(e):
> > return not e.startswith('yes')
> > l.sort(key=key)
> >
> >
> > def original_solution(mylist):
> > for i in range(len(mylist)):
> > if(mylist[i].startswith('yes')):
> > mylist[:] = [mylist[i]] + mylist[:i] + mylist[i+1:]
>
> original_solution() reverses the order of the matches while sort_in_place()
> doesn't. If the order is not relevant I'd try something like
>
> def exchange(items):
> pos = 0
> for index, item in enumerate(items):
> if item.startswith("yes"):
> items[pos], items[index] = item, items[pos]
> pos += 1
>
> > def main():
> > if argv[1] == 'sort_in_place':
> > f = sort_in_place
> > elif argv[1] == 'original_solution':
> > f = original_solution
> > else:
> > raise Exception()
> >
> > nomatches = int(argv[2])
> > matches = int(argv[3])
> >
> > l = ["no_" for _ in range(nomatches)] + ["yes_" for _ in
> > range(matches)]
>
> Python's timsort knows how to deal with (partially) sorted lists. I suggest
> that you add
>
> random.seed(42) # same list for all script invocations
> random.shuffle(l)
>
> here to spread the matches somewhat over the list.
>
> > print(timeit("f(l)", number=100, globals={"f": f, "l": l}))
>
> Remember that f(l) modifies l, so all but the first invocation will see a
> list where all matches are at the beginning. In other words: in 99 out of
> 100 runs the list is already sorted.
>
> While adding the overhead of copying the list I would expect the results of
>
> timeit("f(l[:])", ...)
>
> to be more realistic.
>
> > if __name__ == '__main__':
> > main()
> > $ ./test_sort_prefix.py sort_in_place 100 3
> > 33.260575089996564
> > $ ./test_sort_prefix.py original_solution 100 3
> > 35.93009542999789
> > $
> >
> >
> > in my tests there is no sensible difference between the two solutions...
> > and the number of matches is risible :)
>
> Indeed, as the number of matches rises your sort() approach will likely
> fare
> better.
>
> Your conclusions may be correct, but the benchmark to support them is
> flawed.
>
>
Option 1: scan and match, pop, insert
Scan and match is O(n)
pop is O(n) ... gotta shift everything over one after deleting
insert is O(n) on a list, better use deque.appendleft for O(1)

Option 2: map keyfunc, sort
Mapping the keyfunction is O(n)
(tim)Sorting is O(n log n) worst case, O(n) best case.

Option 1 using a deque will be O(n).
Option 2 will be O(n log n) worst case and O(n) best case.

On small datasets the constant factors matter, but then it's small, so who
cares about speed? (partially joking)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [beginner] What's wrong?

2016-04-02 Thread Michael Selik
On Sat, Apr 2, 2016 at 4:16 AM Chris Angelico  wrote:

> On Sat, Apr 2, 2016 at 3:27 PM, Random832  wrote:
> > On Fri, Apr 1, 2016, at 19:29, Michael Selik wrote:
> >> Humans have always had trouble with this, in many contexts. I remember
> >> being annoyed at folks saying the year 2000 was the first year of the
> new
> >> millennium, rather than 2001. They'd forgotten the Gregorian calendar
> >> starts from AD 1.
> >
> > Naturally, this means the first millennium was only 999 years long, and
> > all subsequent millennia were 1000 years long. (Whereas "millennium" is
> > defined as the set of all years of a given era for a given integer k
> > where y // 1000 == k. How else would you define it?)
> >
> > And if you want to get technical, the gregorian calendar starts from
> > some year no earlier than 1582, depending on the country. The year
> > numbering system has little to do with the calendar type - your
> > assertion in fact regards the BC/AD year numbering system, which was
> > invented by Bede.
> >
> > The astronomical year-numbering system, which does contain a year zero
> > (and uses negative numbers rather than a reverse-numbered "BC" era), and
> > is incidentally used by ISO 8601, was invented by Jacques Cassini in the
> > 17th century.
> >
>
> Are you sure? Because I'm pretty sure these folks were already talking
> about BC.
>
> http://xenohistorian.faithweb.com/holybook/quotes/YK.html
>
>
If they'd only used Unicode, they could have said "þou" in prayer and "ðousand"
for the year.

BTW, I finally know why there are all those "Ye Olde ...".
https://en.wikipedia.org/wiki/Thorn_(letter)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [beginner] What's wrong?

2016-04-02 Thread Chris Angelico
On Sun, Apr 3, 2016 at 1:48 AM, Michael Selik  wrote:
> If they'd only used Unicode, they could have said "þou" in prayer and
> "ðousand" for the year.
>
> BTW, I finally know why there are all those "Ye Olde ...".
> https://en.wikipedia.org/wiki/Thorn_(letter)

Yep! And the letters (thorn and eth) survive in a very few languages
(Icelandic, notably). Fortunately, Python 3 lets you use it in
identifiers.

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


Re: [beginner] What's wrong?

2016-04-02 Thread Marko Rauhamaa
Chris Angelico :

> Yep! And the letters (thorn and eth) survive in a very few languages
> (Icelandic, notably). Fortunately, Python 3 lets you use it in
> identifiers.

While it is fine for Python to support Unicode to its fullest, I don't
think it's a good idea for a programmer to use non-English identifiers.

The (few) keywords are in English anyway. Imagine reading code like
this:

for oppilas in luokka:
if oppilas.hylätty():
oppilas.ilmoita(oppilas.koetulokset)

which looks nauseating whether you are an English-speaker or
Finnish-speaker.


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


tkinter Entry validation modes

2016-04-02 Thread Mark Lawrence via Python-list

A typical call to create an Entry field would be:-

e = Entry(master, validate='all', ...)

Once this call has been made is it possible to change the validation 
mode at runtime?  Background, I'm knocking up an app so I can play with 
the various modes so that I can see how they work, as I'm just venturing 
into the tkinter world.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: [beginner] What's wrong?

2016-04-02 Thread Chris Angelico
On Sun, Apr 3, 2016 at 2:07 AM, Marko Rauhamaa  wrote:
> Chris Angelico :
>
>> Yep! And the letters (thorn and eth) survive in a very few languages
>> (Icelandic, notably). Fortunately, Python 3 lets you use it in
>> identifiers.
>
> While it is fine for Python to support Unicode to its fullest, I don't
> think it's a good idea for a programmer to use non-English identifiers.
>
> The (few) keywords are in English anyway. Imagine reading code like
> this:
>
> for oppilas in luokka:
> if oppilas.hylätty():
> oppilas.ilmoita(oppilas.koetulokset)
>
> which looks nauseating whether you are an English-speaker or
> Finnish-speaker.

I disagree. I've spoken with people who've used that kind of bilingual
hybrid in regular conversation. There's a channel I hang out on that
mainly speaks Turkish, but some sentences are a Turkish-English
hybrid; usually they use Turkish grammar (subject-object-verb), as
that's the native language of most of the people there.

A lot of Python's keywords are derived from English, yes, but once
they've been abbreviated some, and have slid in meaning from their
original words, they become jargon that can plausibly be imported into
other languages. Words like "lambda" aren't English, so other Roman
alphabet languages are at no disadvantage there; words like "def"
might easily acquire back-formation justifications/mnemonics in other
languages. It's only the words that truly are English terms ("while")
that are problematic, and there's only a handful of those to learn.

Of course, there's the whole standard library, which is written in
English. You could translate that without breaking everything, but
it'd be a big job.

The main reason for permitting non-English identifiers is to let
people synchronize on external naming conventions. Suppose you create
a form (web or GUI or something) and ask a human to key in half a
dozen pieces of information, and then do some arithmetic on them. In
English, we can do this kind of thing:

name = input("Object name: ")
length = int(input("Length: "))
width = int(input("Width: "))
height = int(input("Height: "))
volume = length * width * height
print("Volume of %s is: %d" % (name, volume))

Note how every piece of input or output is directly associated with a
keyword, which is used as the identifier in the code. This is
important; when you come to debug code like this (let's assume there's
a lot more of it than this), you can glance at the form, glance at the
code, and not have to maintain a mental translation table. This is why
we use identifiers in the first place - to identify things! Okay. So
far, so good. Let's translate all that into Russian. (I don't speak
Russian, so the actual translation has been done with Google
Translate. Apologies in advance if the Russian text here says
something horribly wrong.)

название = input("Название объекта: ")
длина = int(input("Длина: "))
ширина = int(input("Ширина: "))
высота = int(input("Высота: "))
объем = длина * ширина * высота
print("Объем %s равно %d" % (название, объем))

Its a hybrid of English function names and Russian text strings and
identifiers. But if you force everyone to write their identifiers in
English, all you get is a hybrid of English function names and
identifiers and Russian text strings - no improvement at all! Or, more
likely, you'll get this:

nazvanie = input("Название объекта: ")
dlina = int(input("Длина: "))
shirina = int(input("Ширина: "))
vysota = int(input("Высота: "))
obyem = dlina * shirina * vysota
print("Объем %s равно %d" % (nazvanie, obyem))

Is that an improvement? I don't think so. Far better to let people
write their names in any way that makes sense for their code.

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


Re: [beginner] What's wrong?

2016-04-02 Thread Steven D'Aprano
On Sun, 3 Apr 2016 02:07 am, Marko Rauhamaa wrote:

> I don't think it's a good idea for a programmer to use non-English
> identifiers. 


So you're saying that learning to be a fluent speaker of English is a
pre-requisite of being a programmer?


I'd rather read:

for oppilas in luokka:
if oppilas.hylätty():
oppilas.ilmoita(oppilas.koetulokset)


than either of these:

for cornea in excellence:
if cornea.marooned():
cornea.amuse(cornea.eventualities)


for pupel in clas:
if pupel.abandened():
pupel.plaese(pupel.resolts)



Google translate suggests Marko's code means:

for pupil in class:
if pupil.abandoned():
pupil.please(pupil.results)



-- 
Steven

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


Re: [beginner] What's wrong?

2016-04-02 Thread Marko Rauhamaa
Steven D'Aprano :

> I'd rather read:
>
> for oppilas in luokka:
> if oppilas.hylätty():
> oppilas.ilmoita(oppilas.koetulokset)
>
> [...]
>
> Google translate suggests Marko's code means:
>
> for pupil in class:
> if pupil.abandoned():
> pupil.please(pupil.results)

"Hylätty" in this context means "rejected."

"Ilmoita" means "inform, announce, let know."

> So you're saying that learning to be a fluent speaker of English is a
> pre-requisite of being a programmer?

No more than learning Latin is a prerequisite of being a doctor.

Nowadays software companies and communities are international. You never
know who needs to maintain your code. At work, I need to maintain code
that was created in Japan, with coworkers from all over the world. The
Japanese author had had a hard time with English, and made some
awkward naming choices, but had the common sense to use English-only
names in his code.

I also think log file timestamps should be expressed in UTC.


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


Re: [beginner] What's wrong?

2016-04-02 Thread Thomas 'PointedEars' Lahn
Marko Rauhamaa wrote:

> Steven D'Aprano :
>> So you're saying that learning to be a fluent speaker of English is a
>> pre-requisite of being a programmer?
> 
> No more than learning Latin is a prerequisite of being a doctor.

Full ACK.  Probably starting with the Industrial Revolution enabled by the 
improvements of the steam machine in England, English has become the /lingua 
franca/ of technology (even though the French often still disagree, 
preferring words like « ordinateur » and « octet » over “computer” and 
“byte”, respectively¹).  (With the Internet at the latest, then, it has also 
become the /lingua franca/ of science, although Latin terms are common in 
medicine.)
 
> Nowadays software companies and communities are international. You never
> know who needs to maintain your code. At work, I need to maintain code
> that was created in Japan, with coworkers from all over the world. The
> Japanese author had had a hard time with English, and made some
> awkward naming choices, but had the common sense to use English-only
> names in his code.

One will have a hard time finding a company or community, international or 
not, that does not have at least a basic knowledge of English included in 
what they require of a software developer.


¹  Years ago, I was helping a French colleague with her computer, and
   was surprised to read “Mo” instead of “MB” in the status bar of
   Windows Explorer.
-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: writing to command line thru python gui

2016-04-02 Thread Thomas 'PointedEars' Lahn
A. ElKader wrote:

> I posted this question, no reply :
> 
> Any advice :
> 
> http://unix.stackexchange.com/questions/273573/write-to-terminal-in-tkinter-gui

I do not think that this newsgroup/mailing list is meant as an advertisement 
board to get your questions answered on Q&A forums on the Web, or to get 
your questions answered *here* that you ask *there*.

So if you have a question, you should ask it *here*.  If you do so, you 
would be well-advised to post it using your real name.



-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [beginner] What's wrong?

2016-04-02 Thread Rustom Mody
On Saturday, April 2, 2016 at 10:42:27 PM UTC+5:30, Thomas 'PointedEars' Lahn 
wrote:
> Marko Rauhamaa wrote:
> 
> > Steven D'Aprano :
> >> So you're saying that learning to be a fluent speaker of English is a
> >> pre-requisite of being a programmer?
> > 
> > No more than learning Latin is a prerequisite of being a doctor.
> 
> Full ACK.  Probably starting with the Industrial Revolution enabled by the 
> improvements of the steam machine in England, English has become the /lingua 
> franca/ of technology (even though the French often still disagree, 
> preferring words like « ordinateur » and « octet » over “computer” and 
> “byte”, respectively¹).  (With the Internet at the latest, then, it has also 
> become the /lingua franca/ of science, although Latin terms are common in 
> medicine.)

IMHO the cavalier usage of random alphabet-soup for identifiers
can lead to worse than just aesthetic unpleasantness:
https://en.wikipedia.org/wiki/IDN_homograph_attack

When python went to full unicode identifers it should have also added
pragmas for which blocks the programmer intended to use -- something like
a charset declaration of html.

This way if the programmer says "I want latin and greek"
and then A and Α get mixed up well he asked for it.
If he didn't ask then springing it on him seems unnecessary and uncalled for
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: tkinter Entry validation modes

2016-04-02 Thread Wildman via Python-list
On Sat, 02 Apr 2016 16:11:19 +0100, Mark Lawrence wrote:

> A typical call to create an Entry field would be:-
> 
> e = Entry(master, validate='all', ...)
> 
> Once this call has been made is it possible to change the validation 
> mode at runtime?  Background, I'm knocking up an app so I can play with 
> the various modes so that I can see how they work, as I'm just venturing 
> into the tkinter world.

This is off the top of my head and I have not tested it.
Since validate is a config option this might do it:

e.config(validate='focus')

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [beginner] What's wrong?

2016-04-02 Thread Marko Rauhamaa
Rustom Mody :
> When python went to full unicode identifers it should have also added
> pragmas for which blocks the programmer intended to use -- something
> like a charset declaration of html.

You are being silly.


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


Re: tkinter Entry validation modes

2016-04-02 Thread Terry Reedy

On 4/2/2016 11:11 AM, Mark Lawrence via Python-list wrote:

A typical call to create an Entry field would be:-

e = Entry(master, validate='all', ...)

Once this call has been made is it possible to change the validation
mode at runtime?


AFAIK, every keyword-only configuration option can be changed.

e['validate'] = xyz
e.config(validate=xyz)

--
Terry Jan Reedy

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


Re: [beginner] What's wrong?

2016-04-02 Thread Terry Reedy

On 4/2/2016 11:07 AM, Marko Rauhamaa wrote:


While it is fine for Python to support Unicode to its fullest, I don't
think it's a good idea for a programmer to use non-English identifiers.


Non-English identifiers can written, at least in romanized versions, in 
ascii.



The (few) keywords are in English anyway. Imagine reading code like
this:

 for oppilas in luokka:
 if oppilas.hylätty():
 oppilas.ilmoita(oppilas.koetulokset)

which looks nauseating whether you are an English-speaker or
Finnish-speaker.


Your sense of nausea is different from others, so speak for yourself (as 
you did in the first sentence -- "I don't ...").  People were happily 
and routinely writing thing like the above (minus the accented char) in 
2.x.  I guess they must have kept your code out of your sight.


--
Terry Jan Reedy


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


Re: [beginner] What's wrong?

2016-04-02 Thread Terry Reedy

On 4/2/2016 12:44 PM, Marko Rauhamaa wrote:


Nowadays software companies and communities are international.


Grade school classrooms, especially pre-high school, are not.

> You never know who needs to maintain your code.

For one-off school assignments, nobody other than the author.

> At work, I need to maintain code

that was created in Japan, with coworkers from all over the world. The
Japanese author had had a hard time with English, and made some
awkward naming choices, but had the common sense to use English-only
names in his code.


Could not have been worse than semi-random ascii like x3tu9.


I also think log file timestamps should be expressed in UTC.


I agree.  Any translation to local time should be in the viewer.  I 
presume this is already true for email and news message timestamps.


--
Terry Jan Reedy

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


Python program

2016-04-02 Thread Pythonnoob via Python-list
Hello, 

I am new to Python and programming in general. However, I have gained some 
skills in Python. I have been working with it in order to gain some real world 
problem solving skills for my job. 

I have written a program in Python track the number of visits customers make to 
our business based upon their account numbers. Right now we are doing this via 
paper. We have 7 computers. Each with a different user. We do have a network 
and server. I know this program will run on my computer and I can enter the 
information and update it from my computer. I want all of our associates to 
have the program on their computer and be able to update it in real time. So at 
the end of the day, week, month, etc. the visits can be calculated. I know 
that I can install Python on each of the computers, but I know this would be 
local to their computer. I also know I could have our IT guy install the 
program on the server as well. But in order for the stats to be updated by all 
associates in real time , would I have to build a database and then get that 
installed on the server ?  If so , how would some of you get this done? Besides 
writing the Python program, step by step what would you do and wh
 at other resources would you use to accomplish this?

I am a complete noob at this. Forgive me for not knowing all of the proper 
terminology. I know that there are some real world solutions that Python can 
ultimately offer me and our company. 

Thank you for your time and knowledge !
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Drowning in a teacup?

2016-04-02 Thread Ned Batchelder
On Friday, April 1, 2016 at 4:27:30 PM UTC-4, Fillmore wrote:
> notorious pass by reference vs pass by value biting me in the backside 
> here. Proceeding in order.

As others have pointed out, this is false dichotomy.  There are other
possibilities than pass by reference and pass by value.  Python (and
many other languages) use something called pass by object or pass by
sharing.

This talk has details of how Python's names and values work:
http://nedbatchelder.com/text/names1.html

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


Re: writing to command line thru python gui

2016-04-02 Thread Ned Batchelder
On Saturday, April 2, 2016 at 1:20:52 PM UTC-4, Thomas 'PointedEars' Lahn wrote:
> A. ElKader wrote:
> 
> > I posted this question, no reply :
> > 
> > Any advice :
> > 
> > http://unix.stackexchange.com/questions/273573/write-to-terminal-in-tkinter-gui
> 
> I do not think that this newsgroup/mailing list is meant as an advertisement 
> board to get your questions answered on Q&A forums on the Web, or to get 
> your questions answered *here* that you ask *there*.

Definitely ask your questions here.  We prefer to have a complete conversation
here rather than links off to other sites.

> So if you have a question, you should ask it *here*.  If you do so, you 
> would be well-advised to post it using your real name.

Don't worry about this "real name" idea, it's just one of Thomas' quirks.

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


Re: [beginner] What's wrong?

2016-04-02 Thread Marko Rauhamaa
Terry Reedy :

> On 4/2/2016 12:44 PM, Marko Rauhamaa wrote:
>
>> Nowadays software companies and communities are international.
>
> Grade school classrooms, especially pre-high school, are not.

Parenthetically, English teachers in Finland have been happy with how
teenage boys' English grades have gone up with the advent of online
gaming.

   High school boys get more top scores in English than girls. According
   to a recent master's thesis, the most important causal factor for the
   boys' success is spending a lot of time playing computer games. An
   English language professor wants to raise awareness about the role of
   games for language skills.

   http://yle.fi/uutiset/pojat_kiilaavat_tyttojen_ohi_englannin_
   kielessa_tietokonepelien_ansiosta/5450679>


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


Re: Strange range

2016-04-02 Thread Ned Batchelder
On Friday, April 1, 2016 at 10:34:50 AM UTC-4, Marko Rauhamaa wrote:
> Chris Angelico :
> 
> > *A range object is not an iterator.*
> 
> We now have learned as much.
> 
> However, doesn't that extra level of indirection seem like an odd
> choice?

I agree that it is surprising (and confusing) at first.  It took me
some getting used to.

Now I think of it like this: An iterable is a thing that could be
iterated, that is, it has a sequence of things.  An iterator holds the
current status of a thing that is being iterated.  For example, the
pages of a book are an iterable (we could iterate over them), and a
bookmark is an iterator for the pages of a book: it knows where we are
in the iteration.

This analogy illuminates an important point: a single iterable can have
a number of active iterators working over it at once, just as a book can
have a number of bookmarks in it at once.

nums = [1, 2, 3]
for i in nums:
for j in nums:
print i, j

This prints all the pairs of numbers, because the iterator in the first
loop is independent of the iterator(s) in the second loop, even though
they are iterating over the same iterator (the nums list).  Without the
extra indirection of iterators over iterables, this code would get
tangled up.

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


Re: Drowning in a teacup?

2016-04-02 Thread Random832
On Sat, Apr 2, 2016, at 15:28, Ned Batchelder wrote:
> On Friday, April 1, 2016 at 4:27:30 PM UTC-4, Fillmore wrote:
> > notorious pass by reference vs pass by value biting me in the backside 
> > here. Proceeding in order.
> 
> As others have pointed out, this is false dichotomy.  There are other
> possibilities than pass by reference and pass by value.  Python (and
> many other languages) use something called pass by object or pass by
> sharing.

I think that this arises from a confusion as to what a "value" is in
"pass by value".

The point of it being pass by value is that there is no statement you
can execute in the function that has the effect of an assignment of the
expression that was passed in from the caller. This holds no matter what
kind of object is passed in or what mutable properties it has or does
not have.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Strange range

2016-04-02 Thread Marko Rauhamaa
Ned Batchelder :

> This analogy illuminates an important point: a single iterable can have
> a number of active iterators working over it at once, just as a book can
> have a number of bookmarks in it at once.
>
> nums = [1, 2, 3]
> for i in nums:
> for j in nums:
> print i, j
>
> This prints all the pairs of numbers, because the iterator in the first
> loop is independent of the iterator(s) in the second loop, even though
> they are iterating over the same iterator (the nums list).  Without the
> extra indirection of iterators over iterables, this code would get
> tangled up.

I don't have a problem with a list being a "reiterable." I only was
surprised about range(), which I had thought to be a plain,
down-to-earth iterator. There's barely any other practical use for a
range, I believe.


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


Re: Python program

2016-04-02 Thread Chris Angelico
On Sun, Apr 3, 2016 at 5:14 AM, Pythonnoob via Python-list
 wrote:
> I have written a program in Python track the number of visits customers make 
> to our business based upon their account numbers. Right now we are doing this 
> via paper. We have 7 computers. Each with a different user. We do have a 
> network and server. I know this program will run on my computer and I can 
> enter the information and update it from my computer. I want all of our 
> associates to have the program on their computer and be able to update it in 
> real time. So at the end of the day, week, month, etc. the visits can be 
> calculated. I know that I can install Python on each of the computers, but I 
> know this would be local to their computer. I also know I could have our IT 
> guy install the program on the server as well. But in order for the stats to 
> be updated by all associates in real time , would I have to build a database 
> and then get that installed on the server ?
>

Hi! Welcome to the list. (I'd like to be able to greet you by name,
but I don't think "Noob" is a name. Are you Todd? Or perhaps I can
call you Christine, after CookingForNoobs?)

It might not be *necessary* to do it that way, but I would certainly
recommend it. These days, the easiest way to arrange these sorts of
things would be a web server that manages everything, and have your
associates point their web browsers to it. It's a little bit of work
to set up, but everyone knows how to use a web browser these days, and
they don't need to install Python.

Have you any experience with building web sites in Python? If not,
there are lots of tutorials around. Start with Python 3 and Flask, and
put together an HTML form to accept information from one of your
associates, with another function to process the responses. Use a
PostgreSQL database to store the information, and either psycopg2 or
SQLAlchemy to access that from Python.

There are other ways to do things, but this is how I'd recommend it.

That's a very VERY basic roadmap; it's meant to be enough for you to
recognize which parts you don't know yet. From there, you can
hopefully dig into the project a bit, and add some stats and stuff
like that. Should be fun!

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


Re: Strange range

2016-04-02 Thread Chris Angelico
On Sun, Apr 3, 2016 at 6:44 AM, Marko Rauhamaa  wrote:
> I don't have a problem with a list being a "reiterable." I only was
> surprised about range(), which I had thought to be a plain,
> down-to-earth iterator. There's barely any other practical use for a
> range, I believe.

That's Blub's Paradox right there. There are lots of other uses for
range(), but you just haven't used them.

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


Re: [beginner] What's wrong?

2016-04-02 Thread Michael Selik
On Sat, Apr 2, 2016, 3:40 PM Marko Rauhamaa  wrote:

> Terry Reedy :
>
> > On 4/2/2016 12:44 PM, Marko Rauhamaa wrote:
> >
> >> Nowadays software companies and communities are international.
> >
> > Grade school classrooms, especially pre-high school, are not.
>
> Parenthetically, English teachers in Finland have been happy with how
> teenage boys' English grades have gone up with the advent of online
> gaming.
>
>High school boys get more top scores in English than girls. According
>to a recent master's thesis, the most important causal factor for the
>boys' success is spending a lot of time playing computer games. An
>English language professor wants to raise awareness about the role of
>games for language skills.
>

Gaming also helps your reaction time. Normally 0.3 ms, but 0.1 ms for top
gamers. And fighter pilots.

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


Re: Strange range

2016-04-02 Thread Marko Rauhamaa
Chris Angelico :

> On Sun, Apr 3, 2016 at 6:44 AM, Marko Rauhamaa  wrote:
>> I don't have a problem with a list being a "reiterable." I only was
>> surprised about range(), which I had thought to be a plain,
>> down-to-earth iterator. There's barely any other practical use for a
>> range, I believe.
>
> That's Blub's Paradox right there. There are lots of other uses for
> range(), but you just haven't used them.

That's why I was looking for counterexamples in the standard library
sources but couldn't really spot any (apart from a single
reversed(range())). Maybe I wasn't looking carefully enough.

As far as I can tell, range() is simply Python's way of implementing
classical integral "for" loops.


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


Re: Strange range

2016-04-02 Thread Ned Batchelder
On Saturday, April 2, 2016 at 5:40:35 PM UTC-4, Marko Rauhamaa wrote:
> Chris Angelico :
> 
> > On Sun, Apr 3, 2016 at 6:44 AM, Marko Rauhamaa  wrote:
> >> I don't have a problem with a list being a "reiterable." I only was
> >> surprised about range(), which I had thought to be a plain,
> >> down-to-earth iterator. There's barely any other practical use for a
> >> range, I believe.
> >
> > That's Blub's Paradox right there. There are lots of other uses for
> > range(), but you just haven't used them.
> 
> That's why I was looking for counterexamples in the standard library
> sources but couldn't really spot any (apart from a single
> reversed(range())). Maybe I wasn't looking carefully enough.
> 
> As far as I can tell, range() is simply Python's way of implementing
> classical integral "for" loops.

You can easily use range in my double-loop example, or a variant:

def pairs(n):
nums = range(n)
for i in nums:
for j in nums:
yield i, j

More importantly, range can be useful as an argument to a function that
doesn't realize it's receiving a range, as in the better way to implement
pairs:

from itertools import product

def pairs(n):
return product(range(n), repeat=2)

By making range an iterable like lots of other things, it's more useful
in these kinds of compositional situations.

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


[Beginner] Hanging in the code until I press return, can't figure it out

2016-04-02 Thread Loop.IO
Hey

So I built a keylogger using python as a test, got the code from the tutorial 
online, I want to improve on it to make it more automated, but the issue I'm 
having is it won't create the file until I press return, any clues where I'm 
going wrong?

If I press return it makes the batch file, otherwise it just hangs.

CODE:

import os
from os.path import join

lookfor = "iexplore.exe"
for root, dirs, files in os.walk('C:\\Program Files\\Internet Explorer'):
print "searching", root
if lookfor in files:
print "found: %s" % join(root, lookfor)

import sys

def create():
print("creating new file")

name=raw_input ('C:\\Documents\\PythonCoding\\')+'launch2.bat'


try:
file=open(name,'w')
file.close()

except:
print("error occured")
sys.exit(0)

create()
-- 
https://mail.python.org/mailman/listinfo/python-list


[Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-02 Thread Loop.IO
Hey 

So I built a keylogger using python as a test, got the code from the tutorial 
online, I want to improve on it to make it more automated, but the issue I'm 
having is it won't create the file until I press return, any clues where I'm 
going wrong? 

If I press return it makes the batch file, otherwise it just hangs. 

CODE: 

import os 
from os.path import join 

lookfor = "iexplore.exe" 
for root, dirs, files in os.walk('C:\\Program Files\\Internet Explorer'): 
print "searching", root 
if lookfor in files: 
print "found: %s" % join(root, lookfor) 
 
import sys 

def create(): 
print("creating new file") 

name=raw_input ('C:\\Documents\\PythonCoding\\')+'launch2.bat' 


try: 
file=open(name,'w') 
file.close() 

except: 
print("error occured") 
sys.exit(0) 

create() 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Beginner] Hanging in the code until I press return, can't figure it out

2016-04-02 Thread Chris Angelico
On Sun, Apr 3, 2016 at 7:55 AM, Loop.IO  wrote:
> So I built a keylogger using python as a test, got the code from the tutorial 
> online, I want to improve on it to make it more automated, but the issue I'm 
> having is it won't create the file until I press return, any clues where I'm 
> going wrong?
>
> If I press return it makes the batch file, otherwise it just hangs.
>
> CODE:
>
> name=raw_input ('C:\\Documents\\PythonCoding\\')+'launch2.bat'
>

What's this line supposed to be doing?

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


Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-02 Thread BartC

On 02/04/2016 22:59, Loop.IO wrote:

Hey

So I built a keylogger using python as a test, got the code from the tutorial 
online, I want to improve on it to make it more automated, but the issue I'm 
having is it won't create the file until I press return, any clues where I'm 
going wrong?

If I press return it makes the batch file, otherwise it just hangs.



 name=raw_input ('C:\\Documents\\PythonCoding\\')+'launch2.bat'


You're asking for a file name to be entered. So that if ABC is pressed, 
followed by Enter, it will use:


  C:\Documents\PythonCoding\ABClaunch2.bat

Assuming that's the intention, then Enter is needed so that it knows 
when the user has completed typing the name. If not, then just use:


  name='C:\\Documents\\PythonCoding\\launch2.bat'

(If you want a single character name, without pressing Enter, that's 
harder to do. Someone else will have to help.)


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


Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-02 Thread Ned Batchelder
On Saturday, April 2, 2016 at 6:09:13 PM UTC-4, BartC wrote:
> On 02/04/2016 22:59, Loop.IO wrote:
> > Hey
> >
> > So I built a keylogger using python as a test, got the code from the 
> > tutorial online, I want to improve on it to make it more automated, but the 
> > issue I'm having is it won't create the file until I press return, any 
> > clues where I'm going wrong?
> >
> > If I press return it makes the batch file, otherwise it just hangs.
> 
> >  name=raw_input ('C:\\Documents\\PythonCoding\\')+'launch2.bat'
> 
> You're asking for a file name to be entered. So that if ABC is pressed, 
> followed by Enter, it will use:
> 
>C:\Documents\PythonCoding\ABClaunch2.bat

That line of code will prompt the user:

C:\Documents\PythonCoding\

then the user enters ABC:

C:\Documents\PythonCoding\ABC

and raw_input returns "ABC", so name becomes "ABClaunch2.bat".

Presumably the intention here was to use the prompt as a suggestion
for a value to enter, but I can't be sure.

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


Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-02 Thread Loop.IO
On Saturday, April 2, 2016 at 11:09:13 PM UTC+1, BartC wrote:
> On 02/04/2016 22:59, Loop.IO wrote:
> > Hey
> >
> > So I built a keylogger using python as a test, got the code from the 
> > tutorial online, I want to improve on it to make it more automated, but the 
> > issue I'm having is it won't create the file until I press return, any 
> > clues where I'm going wrong?
> >
> > If I press return it makes the batch file, otherwise it just hangs.
> 
> >  name=raw_input ('C:\\Documents\\PythonCoding\\')+'launch2.bat'
> 
> You're asking for a file name to be entered. So that if ABC is pressed, 
> followed by Enter, it will use:
> 
>C:\Documents\PythonCoding\ABClaunch2.bat
> 
> Assuming that's the intention, then Enter is needed so that it knows 
> when the user has completed typing the name. If not, then just use:
> 
>name='C:\\Documents\\PythonCoding\\launch2.bat'
> 
> (If you want a single character name, without pressing Enter, that's 
> harder to do. Someone else will have to help.)
> 
> -- 
> Bartc

Hey Bartc

I don't quite understand what you mean?

The file is just supposed to be created, I don't want to have to press "Enter" 
or "Return" for it to complete the file creation

the info i followed to create the file advised I had to add the file name and 
extension on after like in the code
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-02 Thread BartC

On 02/04/2016 23:16, Ned Batchelder wrote:

On Saturday, April 2, 2016 at 6:09:13 PM UTC-4, BartC wrote:

On 02/04/2016 22:59, Loop.IO wrote:

Hey

So I built a keylogger using python as a test, got the code from the tutorial 
online, I want to improve on it to make it more automated, but the issue I'm 
having is it won't create the file until I press return, any clues where I'm 
going wrong?

If I press return it makes the batch file, otherwise it just hangs.



  name=raw_input ('C:\\Documents\\PythonCoding\\')+'launch2.bat'


You're asking for a file name to be entered. So that if ABC is pressed,
followed by Enter, it will use:

C:\Documents\PythonCoding\ABClaunch2.bat


That line of code will prompt the user:

 C:\Documents\PythonCoding\

then the user enters ABC:

 C:\Documents\PythonCoding\ABC

and raw_input returns "ABC", so name becomes "ABClaunch2.bat".


Yes, of course. I ran the code and picked up the wrong line even though 
I printed out 'name'!


But, it does look as though that path is supposed to form part of the 
resulting filename.


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


Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-02 Thread Loop.IO
On Saturday, April 2, 2016 at 11:27:49 PM UTC+1, BartC wrote:
> On 02/04/2016 23:16, Ned Batchelder wrote:
> > On Saturday, April 2, 2016 at 6:09:13 PM UTC-4, BartC wrote:
> >> On 02/04/2016 22:59, Loop.IO wrote:
> >>> Hey
> >>>
> >>> So I built a keylogger using python as a test, got the code from the 
> >>> tutorial online, I want to improve on it to make it more automated, but 
> >>> the issue I'm having is it won't create the file until I press return, 
> >>> any clues where I'm going wrong?
> >>>
> >>> If I press return it makes the batch file, otherwise it just hangs.
> >>
> >>>   name=raw_input ('C:\\Documents\\PythonCoding\\')+'launch2.bat'
> >>
> >> You're asking for a file name to be entered. So that if ABC is pressed,
> >> followed by Enter, it will use:
> >>
> >> C:\Documents\PythonCoding\ABClaunch2.bat
> >
> > That line of code will prompt the user:
> >
> >  C:\Documents\PythonCoding\
> >
> > then the user enters ABC:
> >
> >  C:\Documents\PythonCoding\ABC
> >
> > and raw_input returns "ABC", so name becomes "ABClaunch2.bat".
> 
> Yes, of course. I ran the code and picked up the wrong line even though 
> I printed out 'name'!
> 
> But, it does look as though that path is supposed to form part of the 
> resulting filename.
> 
> -- 
> Bartc

Oh i see, so the code prompts for a name.. so i'm more lost than i thought, 
what do I need to change to make it just create the file with the chosen name 
Launch2.bat without the prompt?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-02 Thread Michael Selik
I might be overlooking something, but raw_input (Python 2) and input
(Python 3) won't return the input from sys.stdin until you type ENTER. Or
did I misunderstand the question?

On Sat, Apr 2, 2016 at 6:30 PM BartC  wrote:

> On 02/04/2016 23:16, Ned Batchelder wrote:
> > On Saturday, April 2, 2016 at 6:09:13 PM UTC-4, BartC wrote:
> >> On 02/04/2016 22:59, Loop.IO wrote:
> >>> Hey
> >>>
> >>> So I built a keylogger using python as a test, got the code from the
> tutorial online, I want to improve on it to make it more automated, but the
> issue I'm having is it won't create the file until I press return, any
> clues where I'm going wrong?
> >>>
> >>> If I press return it makes the batch file, otherwise it just hangs.
> >>
> >>>   name=raw_input ('C:\\Documents\\PythonCoding\\')+'launch2.bat'
> >>
> >> You're asking for a file name to be entered. So that if ABC is pressed,
> >> followed by Enter, it will use:
> >>
> >> C:\Documents\PythonCoding\ABClaunch2.bat
> >
> > That line of code will prompt the user:
> >
> >  C:\Documents\PythonCoding\
> >
> > then the user enters ABC:
> >
> >  C:\Documents\PythonCoding\ABC
> >
> > and raw_input returns "ABC", so name becomes "ABClaunch2.bat".
>
> Yes, of course. I ran the code and picked up the wrong line even though
> I printed out 'name'!
>
> But, it does look as though that path is supposed to form part of the
> resulting filename.
>
> --
> Bartc
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Drowning in a teacup?

2016-04-02 Thread Ethan Furman

On 04/02/2016 12:54 PM, Random832 wrote:

On Sat, Apr 2, 2016, at 15:28, Ned Batchelder wrote:

On Friday, April 1, 2016 at 4:27:30 PM UTC-4, Fillmore wrote:

notorious pass by reference vs pass by value biting me in the backside
here. Proceeding in order.


As others have pointed out, this is false dichotomy.  There are other
possibilities than pass by reference and pass by value.  Python (and
many other languages) use something called pass by object or pass by
sharing.


I think that this arises from a confusion as to what a "value" is in
"pass by value".

The point of it being pass by value is that there is no statement you
can execute in the function that has the effect of an assignment of the
expression that was passed in from the caller. This holds no matter what
kind of object is passed in or what mutable properties it has or does
not have.


Also, if "pass-by-value" is being used, even mutation of the passed 
object will not show up in the caller.


--
~Ethan~

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


Re: Drowning in a teacup?

2016-04-02 Thread Random832
On Sat, Apr 2, 2016, at 19:15, Ethan Furman wrote:
> Also, if "pass-by-value" is being used, even mutation of the passed 
> object will not show up in the caller.

I disagree. I don't think the definition of pass-by-value implies this.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [beginner] What's wrong?

2016-04-02 Thread Steven D'Aprano
On Sun, 3 Apr 2016 03:12 am, Thomas 'PointedEars' Lahn wrote:

> Marko Rauhamaa wrote:
> 
>> Steven D'Aprano :
>>> So you're saying that learning to be a fluent speaker of English is a
>>> pre-requisite of being a programmer?
>> 
>> No more than learning Latin is a prerequisite of being a doctor.
> 
> Full ACK.  Probably starting with the Industrial Revolution enabled by the
> improvements of the steam machine in England, English has become the
> /lingua franca/ of technology (even though the French often still
> disagree, preferring words like « ordinateur » and « octet » over
> “computer” and “byte”, respectively¹).  (With the Internet at the latest,
> then, it has also become the /lingua franca/ of science, although Latin
> terms are common in medicine.)

And this is a BAD THING. Monoculture is harmful, and science and technology
is becoming a monoculture: Anglo-American language expressing
Anglo-American ideas, regardless of the nationality of the scientist or
engineer.

During the heyday of the scientific revolution, the sciences and mathematics
were much diverse. Depending on your field, the professional scientist
needed at least a working knowledge of German, French, English and Latin,
possibly some Greek and Russian. Likewise for engineering.

I don't think that it is a coincidence that the great scientific theories
like relativity (both of them), quantum mechanics, evolution by natural
selection and continental drift had time to mature in smaller, national
communities before diffusing out to broader international communities.

Fortunately at least some people are aware of the problem and doing
something about it:

https://blog.stackoverflow.com/2014/02/cant-we-all-be-reasonable-and-speak-english/

Unlike the rest of us, Stackoverflow have actually run the numbers: 

10% of the world's programmers are in China
1.4% of their visits come from China

so either Chinese developers are so brilliant and knowledgeable that they
have no need of Stackoverflow, or they're unable to make use of it because
they cannot participate in English-only forums.


>> Nowadays software companies and communities are international. You never
>> know who needs to maintain your code. At work, I need to maintain code
>> that was created in Japan, with coworkers from all over the world. The
>> Japanese author had had a hard time with English, and made some
>> awkward naming choices, but had the common sense to use English-only
>> names in his code.
> 
> One will have a hard time finding a company or community, international or
> not, that does not have at least a basic knowledge of English included in
> what they require of a software developer.

Particularly if one keeps a Euro-centric perspective and doesn't look to
Asia or Brazil.



-- 
Steven

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


Re: [beginner] What's wrong?

2016-04-02 Thread Mark Lawrence via Python-list

On 02/04/2016 17:31, Dennis Lee Bieber wrote:

On Sat, 2 Apr 2016 19:15:36 +1100, Chris Angelico 
declaimed the following:


On Sat, Apr 2, 2016 at 3:27 PM, Random832  wrote:

On Fri, Apr 1, 2016, at 19:29, Michael Selik wrote:

Humans have always had trouble with this, in many contexts. I remember
being annoyed at folks saying the year 2000 was the first year of the new
millennium, rather than 2001. They'd forgotten the Gregorian calendar
starts from AD 1.


Naturally, this means the first millennium was only 999 years long, and
all subsequent millennia were 1000 years long. (Whereas "millennium" is
defined as the set of all years of a given era for a given integer k
where y // 1000 == k. How else would you define it?)

And if you want to get technical, the gregorian calendar starts from
some year no earlier than 1582, depending on the country. The year
numbering system has little to do with the calendar type - your
assertion in fact regards the BC/AD year numbering system, which was
invented by Bede.

The astronomical year-numbering system, which does contain a year zero
(and uses negative numbers rather than a reverse-numbered "BC" era), and
is incidentally used by ISO 8601, was invented by Jacques Cassini in the
17th century.



Are you sure? Because I'm pretty sure these folks were already talking about BC.


Bede's BC/AD goes back to circa 700AD. It is the use of negative years
for astronomical counting that is circa 1650AD


http://xenohistorian.faithweb.com/holybook/quotes/YK.html


And that I'll take as something suited for the first of April... It's
almost on par with an old story (in Asimov's I think) on why the pyramids
were behind schedule -- among other things, the pile of government mandated
documentation, on clay tablets of course, was becoming larger than the
pyramid being built; the older records (on the bottom of the stack) were
decomposing from the pressure, etc. If I recall, they discover cuneiform as
more condense than hieroglyphics, and then learn of papyrus/ink (but then
have to support an entire industry of workers to transcribe the old clay
tablets...)




Here we go again, yet another completely useless thread that is 
irrelevant to the Python programming language.  Hardly surprising that 
the bots don't bother any more.  Are any of the bots still alive?


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: crash while using PyCharm / Python3

2016-04-02 Thread Daniel Wilcox
Hi Adam, from my mail client sent to python-list directly -- actually
attempting to reply to the OP in the past has generated some weirdness and
bounced messages (probably Gmail attempting to stop me from replying-all
with the OP in the TO line rather than the list.  But the behavior you
mentioned is quite odd.

Here are some message headers I was just looking at, and pasting here to
debug.

1 - Adam (OP)

Message-ID: 

no references

list vars included

2 - from me
Message-ID: 

no references

no list vars included


3 - OP

Message-ID: 
References: 

list vars included

4 - Dirk

Message-ID: <[email protected]>

no references

list vars included



5 - OP

Message-ID: 
References:  


list vars included

6 - OP
Message-ID: 
References:  

 <[email protected]>

7 - OP
Message-ID: 
References:  

 <[email protected]>

8 - Jonathan

Message-ID: 
References:  

 <[email protected]>
 

9 - OP
Message-ID: 
References:  

 <[email protected]> 
 

10 - OP
Message-ID: 
References:  

 <[email protected]> 
  

... my next reply

In-Reply-To: 
References: 

<[email protected]>








and Big Bad Bob by far had the funniest headers (right after my last msg)

References:  

 <[email protected]> 
  
 
In-Reply-To: 
X-Why-Are-You-Looking-Here: Jedi Business, move along
X-Testing: of course!
Message-ID: 


and the message I'm currently replying to ...

Message-ID: 
References: 



So I see a few patterns here -- mostly my Message-IDs never appear in any
References so I'd imagine something building a thread of the messages
wouldn't include mine.  But that makes me worry about delivery or at least
properly threading in other clients as well.

I'm not sure why that is it could be using Gmail for my domain or the Gmail
client itself leaving off the List headers that all the other messages
appear to have.  I might need to try my Mutt config on this account to see
if I get different behavior.

Of course it could be that I'm not seeing all the headers I should on my
own messages, or referring to my messages, because in that case perhaps
Gmail is joining messages in my Sent folder with the thread in another
manner.

I should really get this fixed, it's probably not a good thing to have the
messages vanishing from archives and the like.  If you have a few minutes
and can check Message-IDs and references and other headers from my emails
that'd be awesome and might help me track down what is going on.

Thanks for mentioning this!  Cheers,

=D

On Wed, Mar 23, 2016 at 9:18 PM, Adam  wrote:

>
> "Adam"  wrote in message
> news:[email protected]...
> >
> > Host OS:Ubuntu Desktop 14.04 LTS / Unity
> >
> > System crashed while using PyCharm / Python3.
> > Booting takes forever and stuck at the purple screen with
> > the Ubuntu logo and the five dots cycling.
> > How to fix?
> >
>
> Searching for this thread in a browser lead to
> the code.activestate.com website where
> I see posts from Daniel Wilcox.
> But, in my newsreader, I do not see his posts,
> which is why his posts are not getting any response.
> Daniel, how/where are you responding to this thread?
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-02 Thread Mark Lawrence via Python-list

On 02/04/2016 23:23, Loop.IO wrote:

On Saturday, April 2, 2016 at 11:09:13 PM UTC+1, BartC wrote:

On 02/04/2016 22:59, Loop.IO wrote:

Hey

So I built a keylogger using python as a test, got the code from the tutorial 
online, I want to improve on it to make it more automated, but the issue I'm 
having is it won't create the file until I press return, any clues where I'm 
going wrong?

If I press return it makes the batch file, otherwise it just hangs.



  name=raw_input ('C:\\Documents\\PythonCoding\\')+'launch2.bat'


You're asking for a file name to be entered. So that if ABC is pressed,
followed by Enter, it will use:

C:\Documents\PythonCoding\ABClaunch2.bat

Assuming that's the intention, then Enter is needed so that it knows
when the user has completed typing the name. If not, then just use:

name='C:\\Documents\\PythonCoding\\launch2.bat'

(If you want a single character name, without pressing Enter, that's
harder to do. Someone else will have to help.)

--
Bartc


Hey Bartc

I don't quite understand what you mean?

The file is just supposed to be created, I don't want to have to press "Enter" or 
"Return" for it to complete the file creation

the info i followed to create the file advised I had to add the file name and 
extension on after like in the code



There is no point asking BartC about Python as he has repeatedly stated 
that he knows nothing about Python.  OTOH there are loads of people here 
who do know Python, backwards, sideways and inside out.  If you state 
precisely what you are trying to achieve then you will get the correct 
answer.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-02 Thread BartC

On 02/04/2016 23:31, Loop.IO wrote:


Oh i see, so the code prompts for a name.. so i'm more lost than i thought, 
what do I need to change to make it just create the file with the chosen name 
Launch2.bat without the prompt?


If you don't want the user to enter anything, then I explained how 
before, just use:


 name='C:\\Documents\\PythonCoding\\launch2.bat'

if that's the file name you need.

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


Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-02 Thread Mark Lawrence via Python-list

On 02/04/2016 23:37, Michael Selik wrote:

I might be overlooking something, but raw_input (Python 2) and input
(Python 3) won't return the input from sys.stdin until you type ENTER. Or
did I misunderstand the question?

On Sat, Apr 2, 2016 at 6:30 PM BartC  wrote:


On 02/04/2016 23:16, Ned Batchelder wrote:

On Saturday, April 2, 2016 at 6:09:13 PM UTC-4, BartC wrote:

On 02/04/2016 22:59, Loop.IO wrote:

Hey

So I built a keylogger using python as a test, got the code from the

tutorial online, I want to improve on it to make it more automated, but the
issue I'm having is it won't create the file until I press return, any
clues where I'm going wrong?


If I press return it makes the batch file, otherwise it just hangs.



   name=raw_input ('C:\\Documents\\PythonCoding\\')+'launch2.bat'


You're asking for a file name to be entered. So that if ABC is pressed,
followed by Enter, it will use:

 C:\Documents\PythonCoding\ABClaunch2.bat


That line of code will prompt the user:

  C:\Documents\PythonCoding\

then the user enters ABC:

  C:\Documents\PythonCoding\ABC

and raw_input returns "ABC", so name becomes "ABClaunch2.bat".


Yes, of course. I ran the code and picked up the wrong line even though
I printed out 'name'!

But, it does look as though that path is supposed to form part of the
resulting filename.

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



BartC is renowned for knowing nothing about Python by his own 
admittance, and would you please not top post on the list.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: [beginner] What's wrong?

2016-04-02 Thread Mark Lawrence via Python-list

On 03/04/2016 00:49, Steven D'Aprano wrote:

On Sun, 3 Apr 2016 03:12 am, Thomas 'PointedEars' Lahn wrote:


Marko Rauhamaa wrote:


Steven D'Aprano :

So you're saying that learning to be a fluent speaker of English is a
pre-requisite of being a programmer?


No more than learning Latin is a prerequisite of being a doctor.


Full ACK.  Probably starting with the Industrial Revolution enabled by the
improvements of the steam machine in England, English has become the
/lingua franca/ of technology (even though the French often still
disagree, preferring words like « ordinateur » and « octet » over
“computer” and “byte”, respectively¹).  (With the Internet at the latest,
then, it has also become the /lingua franca/ of science, although Latin
terms are common in medicine.)


And this is a BAD THING. Monoculture is harmful, and science and technology
is becoming a monoculture: Anglo-American language expressing
Anglo-American ideas, regardless of the nationality of the scientist or
engineer.

During the heyday of the scientific revolution, the sciences and mathematics
were much diverse. Depending on your field, the professional scientist
needed at least a working knowledge of German, French, English and Latin,
possibly some Greek and Russian. Likewise for engineering.

I don't think that it is a coincidence that the great scientific theories
like relativity (both of them), quantum mechanics, evolution by natural
selection and continental drift had time to mature in smaller, national
communities before diffusing out to broader international communities.

Fortunately at least some people are aware of the problem and doing
something about it:

https://blog.stackoverflow.com/2014/02/cant-we-all-be-reasonable-and-speak-english/

Unlike the rest of us, Stackoverflow have actually run the numbers:

10% of the world's programmers are in China
1.4% of their visits come from China

so either Chinese developers are so brilliant and knowledgeable that they
have no need of Stackoverflow, or they're unable to make use of it because
they cannot participate in English-only forums.



Nowadays software companies and communities are international. You never
know who needs to maintain your code. At work, I need to maintain code
that was created in Japan, with coworkers from all over the world. The
Japanese author had had a hard time with English, and made some
awkward naming choices, but had the common sense to use English-only
names in his code.


One will have a hard time finding a company or community, international or
not, that does not have at least a basic knowledge of English included in
what they require of a software developer.


Particularly if one keeps a Euro-centric perspective and doesn't look to
Asia or Brazil.



My mum was from Tredegar.  She was very upset because English newspaper 
correspondents were biased against her "boys", and because the selectors 
never even put her into the squad, let alone the starting lineup.


Of course this is completely irrelevant on the Python programming main 
mailing list, but it appears that any old crap is acceptable in the year 
2016.


A Bot, a Bot, any kingdom for a Bot.

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-02 Thread Mark Lawrence via Python-list

On 03/04/2016 01:12, BartC wrote:

On 02/04/2016 23:31, Loop.IO wrote:


Oh i see, so the code prompts for a name.. so i'm more lost than i
thought, what do I need to change to make it just create the file with
the chosen name Launch2.bat without the prompt?


If you don't want the user to enter anything, then I explained how
before, just use:

  name='C:\\Documents\\PythonCoding\\launch2.bat'

if that's the file name you need.



name = r'C:\Documents\PythonCoding\launch2.bat'

Alternatively you could just use a forward slash.

I'm not sure which is the most efficient, I'll leave that to others to test.

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: [beginner] What's wrong?

2016-04-02 Thread Steven D'Aprano
On Sun, 3 Apr 2016 07:42 am, Michael Selik wrote:

> Gaming also helps your reaction time. Normally 0.3 ms, but 0.1 ms for top
> gamers. And fighter pilots.


Does gaming help reaction time, or do only people with fast reaction times
become top gamers?

Personally, in my experience gaming hurts reaction time. I ask people a
question, and they don't reply for a week or at all, because they're too
busy playing games all day.


-- 
Steven

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


Re: [beginner] What's wrong?

2016-04-02 Thread Mark Lawrence via Python-list

On 03/04/2016 01:48, Steven D'Aprano wrote:

On Sun, 3 Apr 2016 07:42 am, Michael Selik wrote:


Gaming also helps your reaction time. Normally 0.3 ms, but 0.1 ms for top
gamers. And fighter pilots.


Does gaming help reaction time, or do only people with fast reaction times
become top gamers?

Personally, in my experience gaming hurts reaction time. I ask people a
question, and they don't reply for a week or at all, because they're too
busy playing games all day.



I must agree.  When you're trying to get the ball away, and 23 stone of 
bone and muscle smashes into you, that slows your reaction time.  I am 
of course referring to the sport of rugby, not that silly "World 
Series", which takes part in only one country, where for some reason 
unknown to me they wear huge quantities of armour and need oxygen masks 
after they've run a few yards.  What would happen to the poor little 
darlings if they had to spend the entire match on the pitch?


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Drowning in a teacup?

2016-04-02 Thread Steven D'Aprano
On Sun, 3 Apr 2016 05:54 am, Random832 wrote:

> On Sat, Apr 2, 2016, at 15:28, Ned Batchelder wrote:
>> On Friday, April 1, 2016 at 4:27:30 PM UTC-4, Fillmore wrote:
>> > notorious pass by reference vs pass by value biting me in the backside
>> > here. Proceeding in order.
>> 
>> As others have pointed out, this is false dichotomy.  There are other
>> possibilities than pass by reference and pass by value.  Python (and
>> many other languages) use something called pass by object or pass by
>> sharing.
> 
> I think that this arises from a confusion as to what a "value" is in
> "pass by value".

I don't understand what you mean by this. Are you defending the idea that
Python is pass-by-value, or saying that Fillmore is confused by what
pass-by-value means, or something else? What precisely are you trying to
say here?



> The point of it being pass by value is that there is no statement you
> can execute in the function that has the effect of an assignment of the
> expression that was passed in from the caller. 

No, that alone is insufficient. There are other calling conventions that
have the same effect. Pass-by-value also requires that the value being
passed is copied.

Unfortunately we've been plagued by a bunch of comp sci graduates who suffer
from the "little bit of learning" problem. Having learned that there are
only two calling conventions, pass by value and pass by reference, and
correctly recognising that their language of choice is not pass by
reference, they then jump through some remarkable intellectual contortions
to prove that it is therefore pass by value.

To do this, they normally redefine "value" to mean something other than what
everyone else thinks of as the value being passed to a function.

The Java community is especially prone to this:

http://javadude.com/articles/passbyvalue.htm

Note the author's definition of pass-by-value:

[quote]
Pass-by-value

The actual parameter (or argument expression) is fully evaluated and the
resulting value is copied into a location being used to hold the formal
parameter's value during method/function execution.
[end quote]


That the value is *copied* is fundamental to pass by value semantics.

The author, Scott Stanchfield, then claims that Java is pass by value. 

(Note: for this entire discussion, I'm referring to boxed values, or
objects, not primitives. There's no dispute that Java is pass by value for
primitives.)

But to make this work, he has to use a bit of slight of hand: what gets
copied in Java function calls is not the value of the argument, but some
abstract reference to that value. There's this invisible abstract reference
is the value of the variable.

He doesn't come right out and say this, but if you read his description of
what Java does, it should be obvious that he thinks of Java variables as
being bound to abstract pointers or references rather than being bound to
objects themselves. Consequently, if you bind a value to a variable name:

String str = "Hello";

then to Stanchfield, the value of the string variable str is presumably
not "Hello", but some unknown and unknowable abstract reference like
0x832fe50.

This is the only way to make sense of his argument. Objects are not copied
when you pass them to a function in Java, but the invisible reference to
the object may be. Fredrik Lundh (the Effbot) quite rightly holds this view
in scorn:


[quote]
I guess you can, in theory, value an artificial number assigned
to an object as much as the object itself.

"Joe, I think our son might be lost in the woods"
"Don't worry, I have his social security number"
[end quote]

http://effbot.org/zone/call-by-object.htm


Stanchfield's view of invisible references to objects being passed by value
is, I have no doubt, right from the perspective of the Java implementation.
Some would argue that he is "technically correct". But he is answering the
wrong question. Calling Java (or Python) "pass by value" gives us no
insight into how the language works. It is reductionism gone mad.

Nobody, except maybe compiler designers, cares how the Java virtual machine
implements argument passing. What Java developers care about is the
behaviour of the Java language. Java's so-called "pass by value (where the
value is some invisible reference to the value you actually care about)"
behaves quite differently from pass by value in C, Pascal and others. Java
doesn't copy objects when you pass them to functions. Nor does it pass
references in pass by reference sense.

Java objects are passed using the exact same semantics as Python objects,
and neither pass by reference nor pass by value match that actual
behaviour. Both languages provide an abstraction layer between the internal
implementation details of the interpreter or virtual machine, and the
high-level behaviour of the language.


Stanchfield makes the same mistake with his claim that "Java has pointers",
since of course it does not. The Java language gives you no way of creating
such pointers to 

Failed to update the os.environ with subprocess.Popen.

2016-04-02 Thread Hongyi Zhao
Hi all,

I use the following code to update the os.environ with subprocess.Popen:

-
from subprocess import Popen

output = Popen("""
/bin/bash <
os.environ.update(line.partition('=')[::2] for line in output.split
('\0'))
AttributeError: 'Popen' object has no attribute 'split'
---

How to solve this issue?
-- 
.: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.
-- 
https://mail.python.org/mailman/listinfo/python-list


Failed to update the os.environ with subprocess.Popen.

2016-04-02 Thread Hongyi Zhao
Hi all,

I use the following code to update the os.environ with subprocess.Popen:

-
from subprocess import Popen

output = Popen("""
/bin/bash <
os.environ.update(line.partition('=')[::2] for line in output.split
('\0'))
AttributeError: 'Popen' object has no attribute 'split'
---

How to solve this issue?
-- 
.: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.
-- 
https://mail.python.org/mailman/listinfo/python-list


Failed to update the os.environ with subprocess.Popen.

2016-04-02 Thread Hongyi Zhao
Hi all,

I use the following code to update the os.environ with subprocess.Popen:

-
from subprocess import Popen

output = Popen("""
/bin/bash <
os.environ.update(line.partition('=')[::2] for line in output.split
('\0'))
AttributeError: 'Popen' object has no attribute 'split'
---

How to solve this issue?
-- 
.: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.
-- 
https://mail.python.org/mailman/listinfo/python-list


Get the output from a Popen instance (was: Failed to update the os.environ with subprocess.Popen.)

2016-04-02 Thread Ben Finney
Hongyi Zhao  writes:

> I use the following code to update the os.environ with
> subprocess.Popen

Again, it is quite misleading to describe what you are doing as “update
the os.environ with subprocess.Popen”.

The ‘subprocess.Popen’ call *cannot* upsdate the Python process's
‘os.environ’.

What you're doing is two quite separate steps:

* Obtain a collection of items (key → value pairs).

* Update a dictionary.

Please be clear that's what you're doing because “update ‘os.environ’
with ‘subprocess.Popen’ is *not* that.

> But, I meet the following errors:
>
> 
> Traceback (most recent call last):
>   File "/home/werner/software/hpc/dft-to-study/jasp/jasp.git/jasp/bin/
> runjasp.py", line 125, in 
> os.environ.update(line.partition('=')[::2] for line in output.split
> ('\0'))
> AttributeError: 'Popen' object has no attribute 'split'
> ---

So your problem is nothing to do with “update ‘os.environ’”. I have
updated the Subject field accordingly.

The problem you're encountering is only to do with ‘subprocess.Popen’.
That should make it much easier to search for the documentation to
understand the problem.

https://docs.python.org/3/library/subprocess.html#subprocess.Popen.stdout>

-- 
 \ “When people believe that they have absolute knowledge, with no |
  `\ test in reality, this [the Auschwitz crematorium] is how they |
_o__) behave.” —Jacob Bronowski, _The Ascent of Man_, 1973 |
Ben Finney

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


Re: Get the output from a Popen instance (was: Failed to update the os.environ with subprocess.Popen.)

2016-04-02 Thread Hongyi Zhao
On Sun, 03 Apr 2016 13:37:24 +1000, Ben Finney wrote:

>> But, I meet the following errors:
>>
>> 
>> Traceback (most recent call last):
>>   File "/home/werner/software/hpc/dft-to-study/jasp/jasp.git/jasp/bin/
>> runjasp.py", line 125, in 
>> os.environ.update(line.partition('=')[::2] for line in output.split
>> ('\0'))
>> AttributeError: 'Popen' object has no attribute 'split'
>> ---
> 
> So your problem is nothing to do with “update ‘os.environ’”. I have
> updated the Subject field accordingly.
> 
> The problem you're encountering is only to do with ‘subprocess.Popen’.
> That should make it much easier to search for the documentation to
> understand the problem.
> 
> https://docs.python.org/3/library/
subprocess.html#subprocess.Popen.stdout>

Thanks a lot, got it. Should be used as follows:

output = Popen("""
/bin/bash 

Re: Failed to update the os.environ with subprocess.Popen.

2016-04-02 Thread Steven D'Aprano
On Sun, 3 Apr 2016 01:29 pm, Hongyi Zhao wrote:

> Hi all,
> 
> I use the following code to update the os.environ with subprocess.Popen:


I don't understand what you are trying to do here. But regardless of your
intention, the problem you have is nothing to do with updating os.environ.
Proof: change the last line from this complicated expression:

os.environ.update(line.partition('=')[::2] for line in output.split('\0'))

to this simple expression:

output.split('\0')

and you will get the same error. os.environ is irrelevant. Your problem is
only with Popen.

What makes you think that Popen objects have a split() method? They are not
documented as having this method:

https://docs.python.org/2/library/subprocess.html

https://docs.python.org/3/library/subprocess.html

https://pymotw.com/2/subprocess/




-- 
Steven

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


Re: [beginner] What's wrong?

2016-04-02 Thread Gregory Ewing

Chris Angelico wrote:

Yep! And the letters (thorn and eth) survive in a very few languages
(Icelandic, notably). Fortunately, Python 3 lets you use it in
identifiers.


This suggests an elegant solution to the problem of whether
"python" should refer to Python 2 or Python 3. The Python 3
link should be "pyþon"!

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


Re: Strange range

2016-04-02 Thread Steven D'Aprano
On Sun, 3 Apr 2016 06:44 am, Marko Rauhamaa wrote:

> I don't have a problem with a list being a "reiterable." I only was
> surprised about range(), which I had thought to be a plain,
> down-to-earth iterator. There's barely any other practical use for a
> range, I believe.

I can understand that you were mistaken. It's an easy mistake to make.

But I don't understand why you seem to be insisting that its somehow a flaw
that (x)range is implemented as a "lazy list" instead of an iterator.

If you want an iterator, it's only a single function call away: iter(r).

In the meantime, range objects provide the full sequence API. They're not
quite full lists, as they don't allow arbitrary orderings or arbitrary
items, so any list method which implies that arbitrary items can be
inserted or deleted are not included.

It also acts as a proof of concept that Python supports intelligent, lazy
objects that can produce values on demand.

If you personally don't see any advantage in this, so be it, but you might
not be aware of the history of (x)range:

Guido in 2001: "Nobody uses this extra functionality, and its buggy, let's
get rid of it."

https://www.python.org/dev/peps/pep-0260/

Feature request in 2004: "Membership testing in xrange objects is horribly
slow. Let's add a __contains__ method."

http://bugs.python.org/issue1002085

(Request rejected, because the __contains__ method was removed in 2002.)

Discussion and feature request in 2007: "We really ought to fix that slow
performance of (x)range membership testing..."

http://bugs.python.org/issue1766304


So it's one of those things on the border of useful or not. Those who use
it, miss it when its gone. Those who don't, don't understand why anyone
wants it.



-- 
Steven

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


Re: [beginner] What's wrong?

2016-04-02 Thread Gregory Ewing

Thomas 'PointedEars' Lahn wrote:
even though the French often still disagree, 
preferring words like « ordinateur » and « octet » over “computer” and 
“byte”, respectively


To be fair, "octet" is a slightly more precise term than
"byte", meaning exactly 8 bits (whereas "byte" could
theoretically mean something else depending on the
context).

There's no excuse for "ordinateur", though. :-)

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


Re: Strange range

2016-04-02 Thread Random832
On Sun, Apr 3, 2016, at 00:43, Steven D'Aprano wrote:
> If you personally don't see any advantage in this, so be it, but you
> might
> not be aware of the history of (x)range:
> 
> Guido in 2001: "Nobody uses this extra functionality, and its buggy,
> let's
> get rid of it."
> 
> https://www.python.org/dev/peps/pep-0260/

Several of those features apparently never did come back. The repeat
count never did (you can't multiply ranges now), and it occurs to me
that slicing a range that has a repeat count is intractable:
(range(3)*2)[1:5] should yield 1, 2, 0, 1, which can't be represented as
a range object. It also doesn't support comparison operations.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Strange range

2016-04-02 Thread Steven D'Aprano
On Sun, 3 Apr 2016 02:43 pm, Steven D'Aprano wrote:

> If you personally don't see any advantage in this, so be it, but you might
> not be aware of the history of (x)range:
> 
> Guido in 2001: "..."

Correction: these are not direct quotes, but paraphrases. My apologies for
any confusion.


-- 
Steven

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


Re: [beginner] What's wrong?

2016-04-02 Thread Steven D'Aprano
On Sun, 3 Apr 2016 02:57 pm, Gregory Ewing wrote:

> Thomas 'PointedEars' Lahn wrote:
>> even though the French often still disagree,
>> preferring words like « ordinateur » and « octet » over “computer” and
>> “byte”, respectively
> 
> To be fair, "octet" is a slightly more precise term than
> "byte", meaning exactly 8 bits (whereas "byte" could
> theoretically mean something else depending on the
> context).

"Theoretically"?

http://stackoverflow.com/questions/2098149/what-platforms-have-something-other-than-8-bit-char






-- 
Steven

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


Re: [beginner] What's wrong?

2016-04-02 Thread Michael Torrie
Mark, your messages are showing up to the list as being from "python,"
at least on my email.  Any reason for this?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Strange range

2016-04-02 Thread Stephen Hansen
On Sat, Apr 2, 2016, at 02:40 PM, Marko Rauhamaa wrote:
> That's why I was looking for counterexamples in the standard library

This entire bent of an argument seems flawed to me.

The standard library has never been a beacon for best practices or
idiomatic uses of Python. That a use exists in the standard library, or
that one does not, doesn't really tell you anything meaningful about
Python itself or good practices with the language. The standard library
is under uniquely conservative constraints that enshrine compatibility
and reliability from one point release to another over any kind of
innovation. 

That code exists in the standard library is, itself, an incredibly
strong reason why it should stay as IS: changes for style, idiom, best
practices, modern techniques, those are all valid but *weak* arguments
to change the standard library. 

The stdlib works and its continuing to work tomorrow is its most
important burden. Just look at how much of the stdlib is not PEP8
compliant. Changing it to be PEP8 compliant is seen as a worse thing to
do then the possibility of introducing bugs by doing such a sweeping
change in the interest of good practices and style.

The stdlib exists as a bastion of stability above all else. Its
standards aren't a reason to make a change (or, not to make a change,
either). That doesn't mean its not useful to look at the standard
library, but you should not enshrine it as the example of good or
idiomatic code to measure decisions against. Most code exists outside
the stdlib. 

---
Stephen Hansen
  m e @ i x o k a i . i o
-- 
https://mail.python.org/mailman/listinfo/python-list