Re: A certainl part of an if() structure never gets executed.

2013-06-13 Thread Νικόλαος Κούρας

On 13/6/2013 4:55 πμ, Steven D'Aprano wrote:

On Wed, 12 Jun 2013 14:17:32 +0300, Νικόλαος Κούρας wrote:


doesn't that mean?

if '=' not in ( name and month and year ):

if '=' does not exists as a char inside the name and month and year
variables?

i think it does, but why it fails then?


No. Python is very close to "English-like", but not exactly, and this is
one of the easiest places to trip.

In English:

"the cat is in the box or the cupboard or the kitchen"

means:

"the cat is in the box, or the cat is in the cupboard, or the cat is in
the kitchen".


But that is not how Python works. In Python, you have to say:

cat in box or cat in cupboard or cat in kitchen


Although this will work as well:

any(cat in place for place in (box, cupboard, kitchen))


In Python, an expression like this:

cat in (box or cupboard or kitchen)


has a completely different meaning. First, the expression in the round
brackets is evaluated:

(box or cupboard or kitchen)


and then the test is performed:

cat in (result of the above)


The expression (box or cupboard or kitchen) means "return the first one
of box, cupboard, kitchen that is a truthy value, otherwise the last
value". Truthy values are those which are considered to be "like True":

truthy values:

- True
- object()
- numbers apart from zero
- non-empty strings
- non-empty lists
- non-empty sets
- non-empty dicts
- etc.

falsey:

- False
- None
- zero (0, 0.0, Decimal(0), Fraction(0), etc.)
- empty string
- empty list
- empty set
- empty dict
- etc.

(Can you see the pattern?)


So you can experiment with this yourself:

42 or 23 or "foo"
=> the first object is truthy, so it is returned

0 or 23 or "foo"
=> the first object is falsey, and the second object is truthy,
so it is returned

0 or [] or "foo"
=> the first two objects are falsey, so the third is returned


The "and" operator works in a similar fashion. Experiment with it and see
how it works for yourself.


I read yours psots many times,all of them, tryign to understand them.


if '-' not in ( name and month and year ):
			cur.execute( '''SELECT * FROM works WHERE clientsID = (SELECT id FROM 
clients WHERE name = %s) and MONTH(lastvisit) = %s and YEAR(lastvisit) = 
%s ORDER BY lastvisit ASC''', (name, month, year) )

elif '-' not in ( name and year ):
			cur.execute( '''SELECT * FROM works WHERE clientsID = (SELECT id FROM 
clients WHERE name = %s) and YEAR(lastvisit) = %s ORDER BY lastvisit 
ASC''', (name, year) )

elif '-' not in ( month and year ):
			cur.execute( '''SELECT * FROM works WHERE MONTH(lastvisit) = %s and 
YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', (month, year) )

elif '-' not in year:
			cur.execute( '''SELECT * FROM works WHERE YEAR(lastvisit) = %s ORDER 
BY lastvisit ASC''', year )


==

i just want 4 cases to examine so correct execute to be run:

i'm reading and reading and reading this all over:

if '-' not in ( name and month and year ):

and i cant comprehend it.

While it seems so beutifull saying:

if character '-' aint contained in string name , neither in string month 
neither in string year.


But it just doesn't work like this.

Since  ( name and month and year ) are all truthy values, what is 
returned by this expression to be checked if it cotnains '=' within it?



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


Re: A few questiosn about encoding

2013-06-13 Thread Steven D'Aprano
On Thu, 13 Jun 2013 09:09:19 +0300, Νικόλαος Κούρας wrote:

> On 13/6/2013 3:13 πμ, Steven D'Aprano wrote:

>> Open an interactive Python session, and run this code:
>>
>> c = ord(16474)
>> len(c.encode('utf-8'))
>>
>>
>> That will tell you how many bytes are used for that example.
> This si actually wrong.
> 
> ord()'s arguments must be a character for which we expect its ordinal
> value.

Gah! 

That's twice I've screwed that up. Sorry about that!


>  >>> chr(16474)
> '䁚'
> 
> Some Chinese symbol.
> So code-point '䁚' has a Unicode ordinal value of 16474, correct?

Correct.

 
> where in after encoding this glyph's ordinal value to binary gives us
> the following bytes:
> 
>  >>> bin(16474).encode('utf-8')
> b'0b10001011010'

No! That creates a string from 16474 in base two:

'0b10001011010'

The leading 0b is just syntax to tell you "this is base 2, not base 8 
(0o) or base 10 or base 16 (0x)". Also, leading zero bits are dropped.

Then you encode the string '0b10001011010' into UTF-8. There are 17 
characters in this string, and they are all ASCII characters to they take 
up 1 byte each, giving you bytes b'0b10001011010' (in ASCII form). In 
hex form, they are:

b'\x30\x62\x31\x30\x30\x30\x30\x30\x30\x30\x31\x30\x31\x31\x30\x31\x30'

which takes up a lot more room, which is why Python prefers to show ASCII 
characters as characters rather than as hex.

What you want is:

chr(16474).encode('utf-8')


[...]
> Thus, there we count 15 bits left.
> So it says 15 bits, which is 1-bit less that 2 bytes. Is the above
> statements correct please?

No. There are 17 BYTES there. The string "0" doesn't get turned into a 
single bit. It still takes up a full byte, 0x30, which is 8 bits.


> but thinking this through more and more:
> 
>  >>> chr(16474).encode('utf-8')
> b'\xe4\x81\x9a'
>  >>> len(b'\xe4\x81\x9a')
> 3
> 
> it seems that the bytestring the encode process produces is of length 3.

Correct! Now you have got the right idea.




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


Re: Version Control Software

2013-06-13 Thread Serhiy Storchaka

13.06.13 05:41, Tim Chase написав(ла):

-hg: last I checked, can't do octopus merges (merges with more than
two parents)

+git: can do octopus merges


Actually it is possible in Mercurial. I just have made a merge of two 
files in CPython test suite (http://bugs.python.org/issue18048).



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


Re: Problem creating a regular expression to parse open-iscsi, iscsiadm output (help?)

2013-06-13 Thread Andreas Perstinger

On 13.06.2013 02:59, rice.cr...@gmail.com wrote:

I am parsing the output of an open-iscsi command that contains
severalblocks of data for each data set. Each block has the format:

[SNIP]

I tried using \s* to swallow the whitespace between the to iSCSI
lines. No joy... However [\s\S]*? allows the regex to succeed. But that
seems to me to be overkill (I am not trying to skip lines of text here.)
Also note that I am using \ + to catch spaces between the words. On the
two problem lines, using \s+ between the label words fails.


Changing

 # Connection state
 iSCSI\ +Connection\ +State:\s+(?P\w+\s*\w*)
 [\s\S]*?<< without this the regex fails
 # Session state
 iSCSI\ +Session\ +State:\s+(?P\w+)


to
# Connection state
iSCSI\s+Connection\s+State:\s+(?P\w+\s*\w*)\s*
# Session state
iSCSI\s+Session\s+State:\s+(?P\w+)

gives me

>>> # 'test' is the example string
>>> myDetails = [ m.groupdict() for m in regex.finditer(test)]
>>> print myDetails
[{'initiatorIP': '221.128.52.214', 'connState': 'LOGGED IN', 'SID': 
'154', 'ipaddr': '221.128.52.224', 'initiatorName': 
'iqn.1996-04.de.suse:01:7c9741b545b5', 'sessionState': 'LOGGED_IN', 
'iqn': 'iqn.1992-04.com.emc:vplex-8460319f-0007', 
'tag': '7', 'port': '3260'}]


for your example (same for the original regex).
It looks like it works (Python 2.7.3) and there is something else 
breaking the regex.


Bye, Andreas
--
http://mail.python.org/mailman/listinfo/python-list


Re: Any speech to text conversation python library for Linux and mac box

2013-06-13 Thread Alan Gauld

On 13/06/13 04:59, Ranjith Kumar wrote:

Hello all,
I'm looking for speech to text conversation python library for linux and
mac box, I found few libraries but non of them supports any of these
platform.


This list is for people learning the python language and standard library.

If you are looking for exotic libraries you should have more success 
posting on the general Python mailing list or newsgroup (comp.lang.python)


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

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


Re: A few questiosn about encoding

2013-06-13 Thread Νικόλαος Κούρας

On 13/6/2013 10:11 πμ, Steven D'Aprano wrote:


  >>> chr(16474)
'䁚'

Some Chinese symbol.
So code-point '䁚' has a Unicode ordinal value of 16474, correct?


Correct.



where in after encoding this glyph's ordinal value to binary gives us
the following bytes:

  >>> bin(16474).encode('utf-8')
b'0b10001011010'


An observations here that you please confirm as valid.

1. A code-point and the code-point's ordinal value are associated into a 
Unicode charset. They have the so called 1:1 mapping.


So, i was under the impression that by encoding the code-point into 
utf-8 was the same as encoding the code-point's ordinal value into utf-8.


That is why i tried to:
bin(16474).encode('utf-8') instead of chr(16474).encode('utf-8')

So, now i believe they are two different things.
The code-point *is what actually* needs to be encoded and *not* its 
ordinal value.




The leading 0b is just syntax to tell you "this is base 2, not base 8
(0o) or base 10 or base 16 (0x)". Also, leading zero bits are dropped.


But byte objects are represented as '\x' instead of the aforementioned 
'0x'. Why is that?



> No! That creates a string from 16474 in base two:
> '0b10001011010'

I disagree here.
16474 is a number in base 10. Doing bin(16474) we get the binary 
representation of number 16474 and not a string.

Why you say we receive a string while python presents a binary number?



Then you encode the string '0b10001011010' into UTF-8. There are 17
characters in this string, and they are all ASCII characters to they take
up 1 byte each, giving you bytes b'0b10001011010' (in ASCII form).


0b10001011010 stands for a number in base 2 for me not as a string.
Have i understood something wrong?


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


Re: Turnign greek-iso filenames => utf-8 iso

2013-06-13 Thread Chris Angelico
On Thu, Jun 13, 2013 at 4:49 PM, Νικόλαος Κούρας  wrote:
> Steven, i can create a normal user account for you and copy files.py into
> your home folder if you want to take a look from within.

At least you're not offering root access any more. But are you aware
that most of your users' files are world-readable? And are you aware
of what that means?

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


Re: A few questiosn about encoding

2013-06-13 Thread Chris Angelico
On Thu, Jun 13, 2013 at 5:42 PM, Νικόλαος Κούρας  wrote:
> On 13/6/2013 10:11 πμ, Steven D'Aprano wrote:
>> No! That creates a string from 16474 in base two:
>> '0b10001011010'
>
> I disagree here.
> 16474 is a number in base 10. Doing bin(16474) we get the binary
> representation of number 16474 and not a string.
> Why you say we receive a string while python presents a binary number?

You can disagree all you like. Steven cited a simple point of fact,
one which can be verified in any Python interpreter. Nikos, you are
flat wrong here; bin(16474) creates a string.

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


Re: Problems with serial port interface

2013-06-13 Thread lionelgreenstreet
I've some other informations:
i've created a class like this

class CReader(QThread):
def start(self, ser, priority = QThread.InheritPriority):
self.ser = ser
QThread.start(self, priority)
self._isRunning = True
self.numData=0;
 
def run(self):
print("Enter Creader")
while True:
if self._isRunning:
try:
data = self.ser.read(self.numData)
n = self.ser.inWaiting()
if n:
data = self.ser.read(n) 
print(data)
except:
errMsg = "Reader thread is terminated unexpectedly."
self.emit(SIGNAL("error(QString)"), errMsg)
else:
return
   
def stop(self):
self._isRunning = False
self.wait()

I've tested my class and it works well and i have no error messages.
So, i think that my problem is this line (taken from previous code)

self.emit(SIGNAL("newData(QString)"), data.decode('cp1252', 'ignore'))

i need this line to display all data received to my QT interface, so can't be 
removed.
I've tried to use a timer to display data every 500ms: my program crasches 
after 5minutes.
Can you help me?
Thanks
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A few questiosn about encoding

2013-06-13 Thread Νικόλαος Κούρας

On 13/6/2013 10:58 πμ, Chris Angelico wrote:

On Thu, Jun 13, 2013 at 5:42 PM,  ��  wrote:

On 13/6/2013 10:11 ��, Steven D'Aprano wrote:

No! That creates a string from 16474 in base two:
'0b10001011010'


I disagree here.
16474 is a number in base 10. Doing bin(16474) we get the binary
representation of number 16474 and not a string.
Why you say we receive a string while python presents a binary number?


You can disagree all you like. Steven cited a simple point of fact,
one which can be verified in any Python interpreter. Nikos, you are
flat wrong here; bin(16474) creates a string.


Indeed python embraced it in single quoting '0b10001011010' and not 
as 0b10001011010 which in fact makes it a string.


But since bin(16474) seems to create a string rather than an expected 
number(at leat into my mind) then how do we get the binary 
representation of the number 16474 as a number?

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


Re: Turnign greek-iso filenames => utf-8 iso

2013-06-13 Thread Νικόλαος Κούρας

On 13/6/2013 10:54 πμ, Chris Angelico wrote:

On Thu, Jun 13, 2013 at 4:49 PM,  ��  wrote:

Steven, i can create a normal user account for you and copy files.py into
your home folder if you want to take a look from within.


At least you're not offering root access any more. But are you aware
that most of your users' files are world-readable? And are you aware
of what that means?


I host no "e-shop" websites, hence into my system there is no credit 
card info stored, no id photos, no SSN, nothing.


Now i checked and most are Joomla files or sites made by DreamWeaver.
and they are 755, that would mean group and word readable, *not* 
writable, so no harm can possibly come out of this.


And even if something could happen, i strongly believe Steven would not 
do it as he is almost(there are others too bu not so frequent and 
detailed helpers) the only one that in fact helps me with my questions 
and i'm seriously considering of paying him to turn my cgi scripts to 
python web frameworks(perhaps 'webpy'), since Django must  be an 
overkill for my case, wouldn't do any harm.

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


Re: A few questiosn about encoding

2013-06-13 Thread Chris Angelico
On Thu, Jun 13, 2013 at 6:08 PM, Νικόλαος Κούρας  wrote:
> On 13/6/2013 10:58 πμ, Chris Angelico wrote:
>>
>> On Thu, Jun 13, 2013 at 5:42 PM,  �� 
>> wrote:
>>
>>> On 13/6/2013 10:11 ��, Steven D'Aprano wrote:

 No! That creates a string from 16474 in base two:
 '0b10001011010'
>>>
>>>
>>> I disagree here.
>>> 16474 is a number in base 10. Doing bin(16474) we get the binary
>>> representation of number 16474 and not a string.
>>> Why you say we receive a string while python presents a binary number?
>>
>>
>> You can disagree all you like. Steven cited a simple point of fact,
>> one which can be verified in any Python interpreter. Nikos, you are
>> flat wrong here; bin(16474) creates a string.
>
>
> Indeed python embraced it in single quoting '0b10001011010' and not as
> 0b10001011010 which in fact makes it a string.
>
> But since bin(16474) seems to create a string rather than an expected
> number(at leat into my mind) then how do we get the binary representation of
> the number 16474 as a number?

In Python 2:
>>> 16474

In Python 3, you have to fiddle around with ctypes, but broadly
speaking, the same thing.

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


Re: My son wants me to teach him Python

2013-06-13 Thread TP
On Wed, Jun 12, 2013 at 1:02 PM, Chris Angelico  wrote:

> I put the question to the
> list, and got back a number of excellent and most useful answers
> regarding book recommendations, and we ended up going with (if memory
> serves me) Think Python [1]
>

Here's a link [1] to Chris' original question (and the following answers
including mine which mentioned Think Python).

Chris' requirements were slightly different. In your case "Python for Kids
- A Playful Introduction to Programming" [2] might be more appropriate as a
first book. Despite the title it covers a wide range of topics
*specifically geared towards writing a game in Python*. See the detailed
table of contents to help decide.

Also Chris has an "unnatural" abhorrence of Python 2.7 :) --- at least as
far as learning Python books. As such he dismissed too early what I think
might be a great initial (or 2nd) book, Hello Python [3]. To requote the
Preface which resonates at least with me:

"I thought back to how I first learned to program. I didn't read an
entire programming book from cover to cover and then write a program
after I knew everything there was to know. Instead I started with a
goal, something that I wanted to do, and worked toward it, figuring
things out as I went. I read programming books from time to time,
but really only to figure out the bits I was stuck on. When I was
done, my programs weren't particularly elegant or fast, but they
were mine---I knew how they worked, and they solved a real problem
that I was having."

Some chapter titles include "Gaming with Pyglet", "Twisted Networking"
(which implements a MUD), and "Django" so it covers quite a bit of ground.
Again see the detailed table of contents.

Notice that the subtitle for Think Python [4] is "How to Think Like a
Computer Scientist" which is not every beginning programmer's goal. Yes,
Think Python is free, and yes it's probably quite good, but it's not for
everyone. In particular the presentation is a lot drier than the above
mentioned books.

Somewhat offtopic but mentioned in the thread: Here's what Elliotte Rusty
Harold had to say about Java Console IO in Java I/O, 2nd Edition (OReilly,
2006) which I recently read while helping somewith with their college Java
(yuck!) homework:

Many common misconceptions about I/O occur because most programmers'
first exposure to I/O is through the console. The console is
convenient for quick hacks and toy examples commonly found in
textbooks, and I will use it for that in this book, but it's really
a very unusual source of input and destination for output, and good
Java programs avoid it. It behaves almost, but not completely,
unlike anything else you'd want to read from or write to. While
consoles make convenient examples in programming texts like this
one, they're a horrible user interface and really have little place
in modern programs. Users are more comfortable with a well-designed
GUI. Furthermore, the console is unreliable across platforms. Many
smaller devices such as Palm Pilots and cell phones have no
console. Web browsers running applets sometimes provide a console
that can be used for output. However, this is hidden by default,
normally cannot be used for input, and is not available in all
browsers on all platforms.

Yikes, a bit opinionated isn't he? Reminds me of some people on this list :)

Finally, regarding sneering at HTML/Javascript. While I've never used the
technology, HTML5/Javascript has the Canvas and possibly WebGL. I've
noticed all sorts of new books on the topic, for example:

Core HTML5 Canvas  Graphics, Animation, and Game Development (Prentice
Hall, 2012)

HTML5 Games Development by Example - Beginner's Guide (Packt, 2011)

HTML5 Games Most Wanted (Friends of Ed, 2012)

Supercharged JavaScript Graphics - With HTML5 Canvas, jQuery, and More
(O'Reilly, 2011)

HTML5 Graphics and Data Visualization Cookbook (Packt, 2012)

This in fact "may" be/is the future of graphics programming (at least in
terms of # of apps written)? And TypeScript [5] "may" make using javascript
(under the hood) less objectionable.

I still agree with your overall approach, learn programming via Python
first --- not for god's sake Java, which colleges still think is the bee's
knees :). But realize that it's only one tool in the programmer's toolkit
and you'll eventually have to learn many languages.

[1] http://mail.python.org/pipermail/python-list/2013-May/646208.html

[2] http://nostarch.com/pythonforkids

[3] http://www.manning.com/briggs/

[4] http://www.greenteapress.com/thinkpython/thinkpython.html

[5] http://www.typescriptlang.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My son wants me to teach him Python

2013-06-13 Thread Chris Angelico
On Thu, Jun 13, 2013 at 6:35 PM, TP  wrote:
> Also Chris has an "unnatural" abhorrence of Python 2.7 :) --- at least as
> far as learning Python books.

Thanks for hunting that thread down, I probably should have back when
I mentioned it :)

As to my abhorrence of Py2 - I don't hate the language (and do use it
at times), but if someone's going to learn programming, s/he should
really learn from something with native Unicode strings. Yes, you
could use Python 2 and open with some future directives, but unless
the course/book is written with that in mind, you'll end up having to
unlearn and relearn to master true Unicode handling. No point doing
that when you can just learn on Python 3!

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


Re: Turnign greek-iso filenames => utf-8 iso

2013-06-13 Thread Chris Angelico
On Thu, Jun 13, 2013 at 6:15 PM, Νικόλαος Κούρας  wrote:
> I host no "e-shop" websites, hence into my system there is no credit card
> info stored, no id photos, no SSN, nothing.
>
> Now i checked and most are Joomla files or sites made by DreamWeaver.
> and they are 755, that would mean group and word readable, *not* writable,
> so no harm can possibly come out of this.

You really want to bet everything that not one of your clients has a
single bit of private information? Have you really learned nothing?

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


Re: Future standard GUI library

2013-06-13 Thread Frank Millman

"Wolfgang Keller"  wrote in message 
news:2013061819.2a044e86ab4b6defe1939...@gmx.net...
>
> But could it be that you have never seen an actually proficient user of
> a typical "enterprise" application (ERP, MRP, whatever) "zipping"
> through the GUI of his/her bread-and-butter application so fast that
> you can not even read the titles of windows or dialog boxes.
>
> Obviously, this won't work if the client runs on this pathological
> non-operating system MS (Not Responding), much less with "web
> applications".
>
[...]
>
>>
>> On a LAN, with a proper back-end, I can get instant response from a
>> web app.
>
> I have been involved as "domain specialist" (and my input has always
> been consistently conveniently ignored) with projects for web
> applications and the results never turned out to be even remotely usable
> for actually productive work.
>

Hi Wolfgang

I share your passion for empowering a human operator to complete and submit 
a form as quickly as possible. I therefore agree that one should be able to 
complete a form using the keyboard only.

There is an aspect I am unsure of, and would appreciate any feedback based 
on your experience.

I am talking about what I call 'field-by-field validation'. Each field could 
have one or more checks to ensure that the input is valid. Some can be done 
on the client (e.g. value must be numeric), others require a round-trip to 
the server (e.g. account number must exist on file). Some applications defer 
the server-side checks until the entire form is submitted, others perform 
the checks in-line. My preference is for the latter.

I agree with Chris that on a LAN, it makes little or no difference whether 
the client side is running a web browser or a traditional gui interface. On 
a WAN, there could be a latency problem. Ideally an application should be 
capable of servicing a local client or a remote client, so it is not easy to 
find the right balance.

Do you have strong views on which is the preferred approach.

Thanks for any input.

Frank Millman



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


Re: Split a list into two parts based on a filter?

2013-06-13 Thread Oscar Benjamin
On 12 June 2013 19:47, Terry Reedy  wrote:
> The proper loop statement
>
> for s in songs:
> (new_songs if s.is_new() else old_songs).append(s)

I think I would just end up rewriting this as

for s in songs:
if s.is_new():
new_songs.append(s)
else:
old_songs.append(s)

but then we're back where we started. I don't think any of the
solutions posted in this thread have been better than this. If you
want to make this a nice one-liner then just put this code in a
function.


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


Re: A few questiosn about encoding

2013-06-13 Thread Νικόλαος Κούρας

On 13/6/2013 11:20 πμ, Chris Angelico wrote:

On Thu, Jun 13, 2013 at 6:08 PM, Νικόλαος Κούρας  wrote:

On 13/6/2013 10:58 πμ, Chris Angelico wrote:


On Thu, Jun 13, 2013 at 5:42 PM,  �� 
wrote:


On 13/6/2013 10:11 ��, Steven D'Aprano wrote:


No! That creates a string from 16474 in base two:
'0b10001011010'



I disagree here.
16474 is a number in base 10. Doing bin(16474) we get the binary
representation of number 16474 and not a string.
Why you say we receive a string while python presents a binary number?



You can disagree all you like. Steven cited a simple point of fact,
one which can be verified in any Python interpreter. Nikos, you are
flat wrong here; bin(16474) creates a string.



Indeed python embraced it in single quoting '0b10001011010' and not as
0b10001011010 which in fact makes it a string.

But since bin(16474) seems to create a string rather than an expected
number(at leat into my mind) then how do we get the binary representation of
the number 16474 as a number?


In Python 2:

16474
typing 16474 in interactive session both in python 2 and 3 gives back 
the number 16474


while we want the the binary representation of the number 16474


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


Re: Turnign greek-iso filenames => utf-8 iso

2013-06-13 Thread Νικόλαος Κούρας

On 13/6/2013 12:25 μμ, Chris Angelico wrote:

On Thu, Jun 13, 2013 at 6:15 PM,  ��  wrote:

I host no "e-shop" websites, hence into my system there is no credit card
info stored, no id photos, no SSN, nothing.

Now i checked and most are Joomla files or sites made by DreamWeaver.
and they are 755, that would mean group and word readable, *not* writable,
so no harm can possibly come out of this.


You really want to bet everything that not one of your clients has a
single bit of private information? Have you really learned nothing?


Yes i can take that bet. All of clients ar also good friends and i know 
their websites and what they are storing, nothing else that each website 
representation, nothing personal.


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


Re: A few questiosn about encoding

2013-06-13 Thread Nobody
On Thu, 13 Jun 2013 12:01:55 +1000, Chris Angelico wrote:

> On Thu, Jun 13, 2013 at 11:40 AM, Steven D'Aprano
>  wrote:
>> The *mechanism* of UTF-8 can go up to 6 bytes (or even 7 perhaps?), but
>> that's not UTF-8, that's UTF-8-plus-extra-codepoints.
> 
> And a proper UTF-8 decoder will reject "\xC0\x80" and "\xed\xa0\x80", even
> though mathematically they would translate into U+ and U+D800
> respectively. The UTF-16 *mechanism* is limited to no more than Unicode
> has currently used, but I'm left wondering if that's actually the other
> way around - that Unicode planes were deemed to stop at the point where
> UTF-16 can't encode any more.

Indeed. 5-byte and 6-byte sequences were originally part of the UTF-8
specification, allowing for 31 bits. Later revisions of the standard
imposed the UTF-16 limit on Unicode as a whole.

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


Re: "Don't rebind built-in names*" - it confuses readers

2013-06-13 Thread Nobody
On Thu, 13 Jun 2013 01:23:27 +, Steven D'Aprano wrote:

> Python does have a globally-global namespace. It is called "builtins", and
> you're not supposed to touch it. Of course, being Python, you can if you
> want, but if you do, you are responsible for whatever toes you shoot off.
> 
> Modifying builtins will effect *all modules*. That's normally too much,
> although it can very, very, very occasionally be useful.

For a specific example, gettext.install() adds the _() function to the
builtins namespace.

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


How to pass instance into decorator function

2013-06-13 Thread Jayakrishnan Damodaran
I have a class which calculates some salary allowances. Instead of a blind 
calculation I need to check some conditions before I can return the calculated 
amount. Like if all the allowances calculated till now plus the one in progress 
must not exceed the total salary(this may occur since these allowances are a 
percentage of basic pay). Below is a sample code FYI

class CompanySalaryBreakUpRule(object):
'''Class to calculate the various salary components.
This class is inherited by individual company classes whom implement salary 
calculations.
Various component calculations are implemented as @property and hence be 
accessed as class properties.

'''
grossPay = 0.0
remainingAmount = 0.0

def checkValid(self, func):
from functools import wraps

@wraps(func)
def wrapper(self, *args, **kwargs):
allowanceToCheck = func(self, *args, **kwargs)
if allowanceToCheck > self.remainingAmount:
allowanceToCheck = self.remainingAmount
else:
self.remainingAmount = self.remainingAmount - allowanceToCheck
return allowanceToCheck
return wrapper

@property
@checkValid
def dearnessAllowance(self):
return self.basic * 0.2 # we have a function that calculates basic pay

But executing this raises an exception
@checkValid
TypeError: checkValid() takes exactly 2 arguments (0 given)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHONPATH: dev and prod

2013-06-13 Thread jacopo
On Wednesday, June 12, 2013 5:10:05 PM UTC+1, rusi wrote:
> On Jun 12, 6:29 pm, jacopo  wrote:
> 
> > > 1. How you run -- 'launch' -- the code -- from py and from prod
> 
> >
> 
> > when I have to test I use "python any_script.py"  but in production there 
> > is a c++ program that is able to wrap and run python code (the technical 
> > details are a bit beyond my knowledge)
> 
> >
> 
> > > 2. What error you get
> 
> >
> 
> > when I run as "python any_script.py" I get
> 
> > "ValueError: Attempted relative import in non-package"
> 
> > I have found this 
> > explanation:http://stackoverflow.com/questions/11536764/attempted-relative-import...
> 
> > So I have added at the top of my module:
> 
> >
> 
> > if __name__=="__main__" and __package__ is None:
> 
> >      __package__="myscripts"
> 
> > from ..mylib import MyClass
> 
> >
> 
> > and I get the error:
> 
> > SystemError: Parent module 'mylib' not loaded, canno perform relative import
> 
> >
> 
> > > 3. Did you try bundling your modules into a package? What problem
> 
> > > happened?
> 
> >
> 
> > What does it mean? what does build mean in this contest? I am not 
> > compiling, I just write the .py files.
> 
> 
> 
> I mean use a python package to wrap the modules.
> 
> Roughly that means have a file named __init__.py in the root of your
> 
> modules directory.
> 
> For the details see http://docs.python.org/2/tutorial/modules.html#packages
> 
> 
> 
> More intricacies I dont know. Hopefully someone who knows better can
> 
> answer

thank you Rusi for your help
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Version Control Software

2013-06-13 Thread Roy Smith
In article <2644d0de-9a81-41aa-b27a-cb4535964...@googlegroups.com>,
 cutems93  wrote:

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

This really doesn't have anything to do with python.  Someplace like 
http://en.wikipedia.org/wiki/Comparison_of_version_control_systems would 
be a good starting point for further research.

If I were to buy a closed-source VCS today, I would look at Perforce 
(www.perforce.com).  I used it for several years.  For small teams, you 
can download and use it for free, so you can play with it without 
commitment.

Perforce tries to solve a somewhat larger problem than just version 
control.  They also do configuration management.  You can set up a 
config-spec which says, "Give me this bunch of files from branch A, that 
bunch of files from branch B, and some third bunch of files which have 
some specific tag.  And, while you're at it, remap the path names so the 
directory structure looks like I want it to".

This configuration management can be a powerful tool when working on a 
huge project.  We threw *everything* into our p4 repo, including the all 
the compilers, development toolchains, and pre-built binaries for all 
the third-party libraries we used.  We also used a single repo shared by 
all the development groups (many 100's of developers on three 
continents).  I would never want to do that in a system like git or hg; 
every developer would have to drag down 100's of GB of crap they didn't 
need.  With p4, we could build people config-specs so they got just the 
parts they needed.

It is also a bit of a steep learning curve to figure out.  Only a few 
people were trusted to do things like build config-specs and create 
shared branches.

As a company, Perforce is a dream to work with.  Their tech support was 
pretty awesome.  I would shoot off an email to supp...@perforce.com, and 
I don't think it ever took more than 5 or 10 minutes for me to get a 
response back from somebody.  And that somebody would inevitably be 
somebody who knew enough to solve my problem, not just some first-line 
support drone.

The costs aren't outrageous, either.  The pricing is a little 
complicated (initial license, annual renewal, various support options, 
of them on a sliding scale based on quantity).  I seem to remember it 
working out to about $100/developer/year for us, but we were buying in 
fairly large quantities.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to pass instance into decorator function

2013-06-13 Thread Peter Otten
Jayakrishnan Damodaran wrote:

> I have a class which calculates some salary allowances. Instead of a blind
> calculation I need to check some conditions before I can return the
> calculated amount. Like if all the allowances calculated till now plus the
> one in progress must not exceed the total salary(this may occur since
> these allowances are a percentage of basic pay). Below is a sample code
> FYI
> 
> class CompanySalaryBreakUpRule(object):
> '''Class to calculate the various salary components.
> This class is inherited by individual company classes whom implement
> salary calculations. Various component calculations are implemented as
> @property and hence be accessed as class properties.
> 
> '''
> grossPay = 0.0
> remainingAmount = 0.0
> 
> def checkValid(self, func):
> from functools import wraps
> 
> @wraps(func)
> def wrapper(self, *args, **kwargs):
> allowanceToCheck = func(self, *args, **kwargs)
> if allowanceToCheck > self.remainingAmount:
> allowanceToCheck = self.remainingAmount
> else:
> self.remainingAmount = self.remainingAmount -
> allowanceToCheck
> return allowanceToCheck
> return wrapper
> 
> @property
> @checkValid
> def dearnessAllowance(self):
> return self.basic * 0.2 # we have a function that calculates basic
> pay
> 
> But executing this raises an exception
> @checkValid
> TypeError: checkValid() takes exactly 2 arguments (0 given)

Remember that

@checkValid
def dearnessAllowance(self): 
...

is a shortcut for

def dearnessAllowance(self): 
...
dearnessAllowance = checkValid(dearnessAllowance)

The function call happens in the class body, so checkValid() is still normal 
function that has knowlegde neither about the class nor (as the self arg 
implies) about an instance of that class. 
While it would be sufficient to remove its first argument

> class CompanySalaryBreakUpRule(object):
  ...
> def checkValid(func):
 ...

> @property
> @checkValid
> def dearnessAllowance(self):
 ...

I recommend that you also move it out of the class body:

  def checkValid(func):
 ...

> class CompanySalaryBreakUpRule(object):
  ...
> @property
> @checkValid
> def dearnessAllowance(self):
 ...


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


Re: Version Control Software

2013-06-13 Thread MRAB

On 13/06/2013 07:00, cutems93 wrote:

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


I've used Microsoft SourceSafe. I didn't like it (does anyone? :-)).
--
http://mail.python.org/mailman/listinfo/python-list


Re: Version Control Software

2013-06-13 Thread rusi
On Jun 13, 4:26 pm, MRAB  wrote:
> On 13/06/2013 07:00, cutems93 wrote:> Thank you everyone for such helpful 
> responses! Actually, I have one
> > more question. Does anybody have experience with closed source
> > version control software? If so, why did you buy it instead of
> > downloading open source software? Does closed source vcs have some
> > benefits over open source in some part?
>
> I've used Microsoft SourceSafe. I didn't like it (does anyone? :-)).

It seems to me that even MS is realizing that SourceSafe's time is
over:

http://techcrunch.com/2013/01/30/microsoft-announces-git-support-for-visual-studio-team-foundation-server-and-service/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A few questiosn about encoding

2013-06-13 Thread Steven D'Aprano
On Thu, 13 Jun 2013 12:41:41 +0300, Νικόλαος Κούρας wrote:

>> In Python 2:
> 16474
> typing 16474 in interactive session both in python 2 and 3 gives back
> the number 16474
> 
> while we want the the binary representation of the number 16474

Python does not work that way. Ints *always* display in decimal. 
Regardless of whether you enter the decimal in binary:

py> 0b10001011010
16474


octal:

py> 0o40132
16474


or hexadecimal:

py> 0x405A
16474


ints always display in decimal. The only way to display in another base 
is to build a string showing what the int would look like in a different 
base:

py> hex(16474)
'0x405a'

Notice that the return value of bin, oct and hex are all strings. If they 
were ints, then they would display in decimal, defeating the purpose!


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


Re: A certainl part of an if() structure never gets executed.

2013-06-13 Thread Zero Piraeus
:

On 12 June 2013 10:55, Neil Cerutti  wrote:
>
> He's definitely trolling. I can't think of any other reason to
> make it so hard to kill-file himself.

He's not a troll, he's a help vampire:

  http://slash7.com/2006/12/22/vampires/

... a particularly extreme example, I'll admit: his lack of
consideration for others apparently knows no bounds. The email thing
is just another aspect of that.

 -[]z.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re-using copyrighted code

2013-06-13 Thread Chris Angelico
On Mon, Jun 10, 2013 at 3:22 AM, Mark Janssen  wrote:
>>> At least partially, my confusion seems to be caused by the dichotomy of
>>> the concepts of copyright and license. How do these relate to each other?
>>
>> A license emerges out of the commercial domain is purely about
>> commercial protections.
>
> I should clarify, that "commercial protections" here means *money*,
> not other potentially legal assets.  As soon as money is exchange you
> entangle yourself with their domain.  Otherwise, as long as you give
> credit, you're really quite safe, from a Constitutional perspective.

Can you quote something regarding this? Also, preferably, can you
quote something international? Because this is an international list,
and an international problem. There is nothing America-specific about
it.

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


Re: My son wants me to teach him Python

2013-06-13 Thread Chris Angelico
On Thu, Jun 13, 2013 at 2:47 PM, Rick Johnson
 wrote:
> On Wednesday, June 12, 2013 11:08:44 PM UTC-5, Chris Angelico wrote:
>
>> No. Definitely not. Programming does NOT begin with a GUI. It begins
>> with something *simple*, so you're not stuck fiddling around with the
>> unnecessary. On today's computers, that usually means console I/O
>> (actually console output, with console input coming along much later).
>
> Chris, you're a dinosaur, only thing is, somebody forgot to tell you.
>
> *Everything* these days revolves around graphical interfaces. The console, 
> which was once the dark and mystical battlefield where knighted geeks would 
> slay the plagues of exception demons, has been reduced to a mere: "little 
> black box of nostalgia".
>
>  1. Rock is dead...
>  2. The console is dead...
>  3. Welcome to the 21st century Chris!
>
> PS: Although i'll bet you think the "rock is dead" mantra is relatively 
> recent, nope! Jim Morrison was singing about it waaay back in 1969!

1. Rock is not dead, remove the covering paper and you'll find it's
happily smashed scissors.

2. The console is healthy. It's often now seen alongside a GUI, with
neither being by any means dead. And "glass teletype" is still the
easiest UI to program for in any language.

3. Thanks! I've been here for a while, but it's still nice to be made welcome.

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


Re: Version Control Software

2013-06-13 Thread rusi
On Jun 13, 7:30 am, Ben Finney  wrote:
>
> You should be wary of GitHub, a very popular Git hosting site. It uses
> what amount to proprietary protocols, which encourage using GitHub's
> specific interface instead of native Git for your operations and hide a
> lot of the needless complexity; but this results in a VCS repository
> that is difficult to use *without* being tied to that specific site,
> killing one of the best reasons to use a DVCS in the first place.

bitbucket -- originally only Hg based -- now supports Hg or git.
And for small private (non open source) repos its more affordable
http://tilomitra.com/bitbucket-vs-github/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie: question regarding references and class relationships

2013-06-13 Thread Rui Maciel
Rick Johnson wrote:

> On Monday, June 10, 2013 8:18:52 AM UTC-5, Rui Maciel wrote:
>> [...]
>>
>> 
>> class Point:
>> position = []
>> def __init__(self, x, y, z = 0):
>> self.position = [x, y, z]
> 
> Firstly. Why would you define a Point object that holds it's x,y,z values
> in a list attribute? Why not store them as self.x, self.y and self.z? 


The position in space is represented as a vector, which is then used in a 
series of operations.  

Currently I'm using numpy arrays to represent vectors.


> Secondly, why would store the position of the Point as a class attribute?


I've answered this 3 days ago.  I'm still learning Python, and python.org's 
tutorial on classes didn't explicitly covered the differences between class 
and instance attributes.


> If you construct your code properly this can be achieved. If each point is
> an object, and lines are merely holding references to two point objects
> that define the start and end position of an imaginary "line", then
> updates on the points will be reflected in the Line object.

This was already covered three days ago in another post in this thread.  
I'll quote the post below


I've tested the following:


model = Model()
model.points.append(Point(1,2))
model.points.append(Point(1,4))

line = Line( model.points[0], model.points[1])

# Case A: this works
model.points[0].position = [2,3,4]
line.points

# Case B: this doesn't work
test.model.points[0] = test.Point(5,4,7)
line.points



Is there a Python way of getting the same effect with Case B?


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


Re: A certainl part of an if() structure never gets executed.

2013-06-13 Thread Sibylle Koczian

Am 13.06.2013 09:11, schrieb Νικόλαος Κούρας:

On 13/6/2013 4:55 πμ, Steven D'Aprano wrote:


The "and" operator works in a similar fashion. Experiment with it and see
how it works for yourself.


I read yours psots many times,all of them, tryign to understand them.



But you didn't do what he recommended, did you? And it's really the best 
or possibly the only way to understanding.


Try it out in the interactive Shell, using Stevens examples connected 
with 'and' instead of 'or'.


Sibylle




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


Re: Version Control Software

2013-06-13 Thread Tim Chase
On 2013-06-13 10:20, Serhiy Storchaka wrote:
> 13.06.13 05:41, Tim Chase написав(ла):
> > -hg: last I checked, can't do octopus merges (merges with more
> > than two parents)
> >
> > +git: can do octopus merges
> 
> Actually it is possible in Mercurial.

Okay, then that moots this pro/con pair.  I seem to recall that at
one point in history, Mercurial required you to do pairwise merges
rather than letting you merge multiple branches in one pass.

-tkc



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


Re: A certainl part of an if() structure never gets executed.

2013-06-13 Thread rusi
On Jun 12, 8:20 pm, Zero Piraeus  wrote:
> :
>
> On 12 June 2013 10:55, Neil Cerutti  wrote:
>
>
>
> > He's definitely trolling. I can't think of any other reason to
> > make it so hard to kill-file himself.
>
> He's not a troll, he's a help vampire:
>
>  http://slash7.com/2006/12/22/vampires/
>
> ... a particularly extreme example, I'll admit

Thanks for that term.

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


Re: A certainl part of an if() structure never gets executed.

2013-06-13 Thread Neil Cerutti
On 2013-06-12, Zero Piraeus  wrote:
> On 12 June 2013 10:55, Neil Cerutti  wrote:
>>
>> He's definitely trolling. I can't think of any other reason to
>> make it so hard to kill-file himself.
>
> He's not a troll, he's a help vampire:
>
>   http://slash7.com/2006/12/22/vampires/
>
> ... a particularly extreme example, I'll admit: his lack of
> consideration for others apparently knows no bounds. The email thing
> is just another aspect of that.

He's also changed his NNTP-Posting-Host, just yesterday, along
with at least three changes in From address, and one change in
Reply-To.

And to start with he came here with an obvious troll name.

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


Re: Version Control Software

2013-06-13 Thread Rui Maciel
Roy Smith wrote:

> In article <98c13a55-dbf2-46a7-a2aa-8c5f052ff...@googlegroups.com>,
>  cutems93  wrote:
> 
>> I am looking for an appropriate version control software for python
>> development, and need professionals' help to make a good decision.
>> Currently I am considering four software: git, SVN, CVS, and Mercurial.
> 
> CVS is hopelessly obsolete.  SVN pretty much the same.

I would say that SVN does have its uses, but managing software repositories 
isn't one of them due to the wealth of available alternatives out there 
which are far better than it.


> Git and Mercurial are essentially identical in terms of features; which
> you like is as much a matter of personal preference as anything else.
> Pick one and learn it.

I agree, but there is a feature Git provides right out of the box which is 
extremelly useful but Mercurial supports only as a non-standard module: the 
git stash feature.


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


Newbie: standard way to add version, author and license to a source file?

2013-06-13 Thread Rui Maciel
Is there any PEP that establishes a standard way to specify the version 
number of a source code file, as well as its authors and what license it's 
distributed under?


Thanks in advance,
Rui Maciel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Version Control Software

2013-06-13 Thread Roy Smith
In article ,
 Tim Chase  wrote:

> On 2013-06-13 10:20, Serhiy Storchaka wrote:
> > 13.06.13 05:41, Tim Chase написав(ла):
> > > -hg: last I checked, can't do octopus merges (merges with more
> > > than two parents)
> > >
> > > +git: can do octopus merges
> > 
> > Actually it is possible in Mercurial.
> 
> Okay, then that moots this pro/con pair.  I seem to recall that at
> one point in history, Mercurial required you to do pairwise merges
> rather than letting you merge multiple branches in one pass.
> 
> -tkc

So, I guess the next questions is, why would you *want* to merge 
multiple branches in one pass?  What's the use case?  I've been using 
VCSs for a long time (I've used RCS, CVS, ClearCase, SVN (briefly), 
Perforce, Git, and hg).  I can't ever remember a time when I've wanted 
to do such a thing.  Maybe it's the kind of thing that makes sense on a 
huge distributed project with hundreds of people committing patches 
willy-nilly?

How would hg even represent such a multi-way merge?  Doesn't every 
revision have exactly one or two parents?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie: standard way to add version, author and license to a source file?

2013-06-13 Thread Robert Kern

On 2013-06-13 13:47, Rui Maciel wrote:

Is there any PEP that establishes a standard way to specify the version
number of a source code file, as well as its authors and what license it's
distributed under?


As for versions:

  http://www.python.org/dev/peps/pep-0396/

For licenses and author:

  http://producingoss.com/en/license-quickstart.html#license-quickstart-applying

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: Wrong website loaded when other requested

2013-06-13 Thread Mark Lawrence

On 12/06/2013 21:19, Chris Angelico wrote:

On Thu, Jun 13, 2013 at 3:33 AM, Νικόλαος Κούρας  wrote:

Why is pointing to /home/nikos isntead of /home/dauwin ?


Why is question pointing to python-list@python.org isntead [sic] of
your home town and some paid support?

ChrisA



Surely support at superhost dot greece should be able to sort all this out?

--
"Steve is going for the pink ball - and for those of you who are 
watching in black and white, the pink is next to the green." Snooker 
commentator 'Whispering' Ted Lowe.


Mark Lawrence

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


Re: My son wants me to teach him Python

2013-06-13 Thread rusi
On Jun 13, 12:46 am, John Ladasky  wrote:
> Hi folks,
>
> My son is 17 years old.  He just took a one-year course in web page design at 
> his high school.  HTML is worth knowing, I suppose, and I think he has also 
> done a little Javascript.  He has expressed an interest in eventually wanting 
> to program 3D video games.
>
> For that purpose, HTML and Javascript are too limited.  I hardly consider 
> either one to be a real programming language.  I want to get him started with 
> a real applications programming language -- Python, of course.  And he's 
> ready to learn.  OK, so it's not necessarily a fast enough language for the 
> epic video games he envisions, but it's a darn good start.  I'll tax his 
> brain with a compiled language like C at some other time.
>
> He's a smart kid, but prefers to be shown, to be tutored, rather than having 
> the patience to sit down and RTFM.  Have any of you been down this road 
> before?  I would appreciate it if you would share your experiences, or 
> provide resource material.
>
> Thanks!

Some views of mine (controversial!).

Python is at least two things, a language and a culture.
As a language its exceptionally dogma-neutral.
You can do OO or FP, throwaway one-off scripts or long-term system
building etc

However as a culture it seems to prefer the OO style to the FP style.
This is unfortunate given that OO is on the down and FP is on a rise.
Some thoughts re OOP: 
http://blog.languager.org/2012/07/we-dont-need-no-o-orientation-4.html

So my suggestion is use some rigorous FPL like Haskell to learn/teach
programming.
After that you can switch to python or some other realistic language.

Note: I have some serious reservations regarding Haskell
http://blog.languager.org/2012/08/functional-programming-philosophical.html
Nevertheless it seems to be the best there is at the moment.

tl;dr: Haskell is in 2013 what Pascal was in 1970 -- good for
programming pedagogy.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A certainl part of an if() structure never gets executed.

2013-06-13 Thread Roy Smith
In article 
<8a75b1e4-41e8-45b5-ac9e-6611a4698...@g9g2000pbd.googlegroups.com>,
 rusi  wrote:

> On Jun 12, 8:20 pm, Zero Piraeus  wrote:
> > :
> >
> > On 12 June 2013 10:55, Neil Cerutti  wrote:
> >
> >
> >
> > > He's definitely trolling. I can't think of any other reason to
> > > make it so hard to kill-file himself.
> >
> > He's not a troll, he's a help vampire:
> >
> >  http://slash7.com/2006/12/22/vampires/
> >
> > ... a particularly extreme example, I'll admit
> 
> Thanks for that term.

Yeah.  I've never heard that before, but it's perfect.
-- 
http://mail.python.org/mailman/listinfo/python-list


Must we include urllib just to decode a URL-encoded string, when using Requests?

2013-06-13 Thread Dotan Cohen
I am using the Requests module to access remote URLs. Sometimes I need
to URL-decode or URL-encode a string (via RFC 3986). Must I import
urllib or urllib2 just to use their quote() and unquote() methods?
Does not Requests have such an ability, and perhaps I just cannot find
it?

On Stack Overflow [1] I found this wonderful function:
def unquote(url):
  return re.compile('%([0-9a-fA-F]{2})',re.M).sub(lambda m:
chr(int(m.group(1),16)), url)

I am already importing the 're' module so that is not an issue. I am
concerned, though, that this might not work for some non-ASCII
characters such as some esoteric symbols or Korean/Chinese/Japanese
characters.

[1] http://stackoverflow.com/a/15627281/343302

--
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My son wants me to teach him Python

2013-06-13 Thread Roy Smith
In article 
<545a441b-0c2d-4b1e-82ae-024b011a4...@e1g2000pbo.googlegroups.com>,
 rusi  wrote:

> Python is at least two things, a language and a culture.

This is true of all languages.  Hang out on the PHP, Ruby, Python, etc, 
forums and you quickly learn that the cultures are as different (or more 
so) than the languages.

The same is true for the human race.  The human race is what it is 
partly because of the DNA we mix-and-match every generation, but also 
because of the information we pass from brain to brain.  Neither one 
tells the full story of what we are.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Must we include urllib just to decode a URL-encoded string, when using Requests?

2013-06-13 Thread Robert Kern

On 2013-06-13 14:05, Dotan Cohen wrote:

I am using the Requests module to access remote URLs. Sometimes I need
to URL-decode or URL-encode a string (via RFC 3986). Must I import
urllib or urllib2 just to use their quote() and unquote() methods?


Yes. Do you think there is a problem with doing so?

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: Must we include urllib just to decode a URL-encoded string, when using Requests?

2013-06-13 Thread Dotan Cohen
On Thu, Jun 13, 2013 at 4:20 PM, Robert Kern  wrote:
> Yes. Do you think there is a problem with doing so?
>

I'm pretty sure that Requests will use either urllib or urllib2,
depending on what is available on the server. I would like to use
whatever Requests is currently using, rather than import the other.
Can I tell which library Requests is currently using and use that?

--
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Must we include urllib just to decode a URL-encoded string, when using Requests?

2013-06-13 Thread Robert Kern

On 2013-06-13 14:25, Dotan Cohen wrote:

On Thu, Jun 13, 2013 at 4:20 PM, Robert Kern  wrote:

Yes. Do you think there is a problem with doing so?


I'm pretty sure that Requests will use either urllib or urllib2,
depending on what is available on the server.


No, it doesn't. It gets its quote() function from urllib always.


I would like to use
whatever Requests is currently using, rather than import the other.
Can I tell which library Requests is currently using and use that?


The only thing I can think that you are talking about is the difference between 
Python 2 and Python 3. In Python 2, it's urllib.quote() and in Python 3, it's 
urllib.parse.quote(), but that's a Python-version issue, not something to do 
with requests, per se. requests does have a compatibility layer, internally, 
that pastes over those issues, but I don't think that is intended to be a stable 
public API that you should rely on. You should handle that kind of switch 
yourself if you care about compatibility across both versions of Python.


https://github.com/kennethreitz/requests/blob/master/requests/compat.py#L86

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: My son wants me to teach him Python

2013-06-13 Thread rusi
On Jun 13, 6:07 pm, Roy Smith  wrote:
> In article
> <545a441b-0c2d-4b1e-82ae-024b011a4...@e1g2000pbo.googlegroups.com>,
>
>  rusi  wrote:
> > Python is at least two things, a language and a culture.
>
> This is true of all languages.  Hang out on the PHP, Ruby, Python, etc,
> forums and you quickly learn that the cultures are as different (or more
> so) than the languages.

Umm... Of course. I dont know though how that relates to the OP's
question.
So let me try state my point differently:

Python-the-language has strengths that are undermined by the biases in
the culture of Python.
A father wanting to give his son the best may want to apply correcting
anti-biases.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Must we include urllib just to decode a URL-encoded string, when using Requests?

2013-06-13 Thread Dotan Cohen
On Thu, Jun 13, 2013 at 4:34 PM, Robert Kern  wrote:
>> I'm pretty sure that Requests will use either urllib or urllib2,
>> depending on what is available on the server.
>
> No, it doesn't. It gets its quote() function from urllib always.
>

I see, thanks. Then that is what I will do as well!

>> I would like to use
>> whatever Requests is currently using, rather than import the other.
>> Can I tell which library Requests is currently using and use that?
>
>
> The only thing I can think that you are talking about is the difference
> between Python 2 and Python 3. In Python 2, it's urllib.quote() and in
> Python 3, it's urllib.parse.quote(), but that's a Python-version issue, not
> something to do with requests, per se. requests does have a compatibility
> layer, internally, that pastes over those issues, but I don't think that is
> intended to be a stable public API that you should rely on. You should
> handle that kind of switch yourself if you care about compatibility across
> both versions of Python.
>
> https://github.com/kennethreitz/requests/blob/master/requests/compat.py#L86
>

Great, thank you Robert. I see that Requests is calling both urllib
and urllib2. For some reason I thought that is rather wasteful and
should be avoided. I was probably wrong!

--
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Must we include urllib just to decode a URL-encoded string, when using Requests?

2013-06-13 Thread Dotan Cohen
On Thu, Jun 13, 2013 at 4:44 PM, Burak Arslan
 wrote:
> On 06/13/13 16:25, Dotan Cohen wrote:
> paste this to your python console, it'll show you what modules requests
> imports:
>
> import sys
> p = set(sys.modules)
> import requests
> for m in sorted(set(sys.modules) - p):
>   print(m)
>

Thank you. Python is a beautiful language, I cannot believe that the
set(sys.modules)-p line does what it does!

Interestingly, on my system with Python3 neither urllib nor urllib2
are imported, only urllib3 which I had not heard of until now:

__future__
_json
atexit
cgi
chardet
html
http.cookiejar
http.cookies
json
json.decoder
json.encoder
json.scanner
logging
mimetypes
netrc
queue
requests
requests.api
requests.auth
requests.compat
requests.cookies
requests.defaults
requests.exceptions
requests.hooks
requests.models
requests.sessions
requests.status_codes
requests.structures
requests.utils
shlex
six
six.moves
threading
urllib3
urllib3._collections
urllib3.connectionpool
urllib3.exceptions
urllib3.filepost
urllib3.packages
urllib3.packages.mimetools_choose_boundary
urllib3.packages.ssl_match_hostname
urllib3.poolmanager
urllib3.request
urllib3.response
urllib3.util


--
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Must we include urllib just to decode a URL-encoded string, when using Requests?

2013-06-13 Thread Burak Arslan

On 06/13/13 16:25, Dotan Cohen wrote:

On Thu, Jun 13, 2013 at 4:20 PM, Robert Kern  wrote:

Yes. Do you think there is a problem with doing so?


I'm pretty sure that Requests will use either urllib or urllib2,
depending on what is available on the server. I would like to use
whatever Requests is currently using, rather than import the other.
Can I tell which library Requests is currently using and use that?



paste this to your python console, it'll show you what modules requests 
imports:



import sys
p = set(sys.modules)
import requests
for m in sorted(set(sys.modules) - p):
  print(m)


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


Re: Future standard GUI library

2013-06-13 Thread Chris Angelico
On Thu, Jun 13, 2013 at 7:32 PM, Frank Millman  wrote:
> I am talking about what I call 'field-by-field validation'. Each field could
> have one or more checks to ensure that the input is valid. Some can be done
> on the client (e.g. value must be numeric), others require a round-trip to
> the server (e.g. account number must exist on file). Some applications defer
> the server-side checks until the entire form is submitted, others perform
> the checks in-line. My preference is for the latter.

It's not either-or. The server *MUST* perform the checks at the time
of form submission; the question is whether or not to perform
duplicate checks earlier. This is an absolute rule of anything where
the client is capable of being tampered with, and technically, you
could violate it on a closed system; but it's so easy to migrate from
closed system to diverse system without adding all the appropriate
checks, so just have the checks from the beginning.

In terms of software usability, either is acceptable, but do make sure
the user can continue working with the form even if there's latency
talking to the server - don't force him/her to wait while you check if
the previous field was valid. I know that seems obvious, but
apparently not to everyone, as there are forms out there that violate
this...

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


Re: Newbie: question regarding references and class relationships

2013-06-13 Thread Chris Angelico
On Thu, Jun 13, 2013 at 10:06 PM, Rui Maciel  wrote:
> Rick Johnson wrote:
>> Firstly. Why would you define a Point object that holds it's x,y,z values
>> in a list attribute? Why not store them as self.x, self.y and self.z?
> 
>
> The position in space is represented as a vector, which is then used in a
> series of operations.
>
> Currently I'm using numpy arrays to represent vectors.
>
>
>> Secondly, why would store the position of the Point as a class attribute?
> 
>
> I've answered this 3 days ago.  I'm still learning Python, and python.org's
> tutorial on classes didn't explicitly covered the differences between class
> and instance attributes.

Just FYI, Rick Johnson (aka Ranting Rick) is a known troll. Don't let
him goad you :)

Follow other people's advice, and take Rick's posts with a grain of
salt. Sometimes he has a good point to make (more often when he's
talking about tkinter, which is his area of expertise), but frequently
he spouts rubbish.

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


Re: A few questiosn about encoding

2013-06-13 Thread Νικόλαος Κούρας

On 13/6/2013 2:49 μμ, Steven D'Aprano wrote:

Please confirm these are true statement:

A code-point and the code-point's ordinal value are associated into a 
Unicode charset. They have the so called 1:1 mapping.


So, i was under the impression that by encoding the code-point into 
utf-8 was the same as encoding the code-point's ordinal value into utf-8.


So, now i believe they are two different things.
The code-point *is what actually* needs to be encoded and *not* its 
ordinal value.



> The leading 0b is just syntax to tell you "this is base 2, not base 8
> (0o) or base 10 or base 16 (0x)". Also, leading zero bits are dropped.

But byte objects are represented as '\x' instead of the aforementioned 
'0x'. Why is that?



ints always display in decimal. The only way to display in another base
is to build a string showing what the int would look like in a different
base:

py> hex(16474)
'0x405a'

Notice that the return value of bin, oct and hex are all strings. If they
were ints, then they would display in decimal, defeating the purpose!


Thank you didn't knew that! indeed it working like this.

To encode a number we have to turn it into a string first.

"16474".encode('utf-8')
b'16474'

That 'b' stand for bytes.
How can i view this byte's object representation as hex() or as bin()?


Also:
>>> len('0b10001011010')
17

You said this string consists of 17 chars.
Why the leading syntax of '0b' counts as bits as well? Shouldn't be 15 
bits instead of 17?




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


Re: Wrong website loaded when other requested

2013-06-13 Thread Νικόλαος Κούρας

On 13/6/2013 9:41 πμ, Νικόλαος Κούρας wrote:

On 12/6/2013 11:35 μμ, Joel Goldstick wrote:




On Wed, Jun 12, 2013 at 1:33 PM, Νικόλαος Κούρας mailto:supp...@superhost.gr>> wrote:

==
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^/?(.+\.html)
/cgi-bin/metrites.py?file=%{__REQUEST_FILENAME} [L,PT,QSA]
==

[code]
file = form.getvalue('file')
page = form.getvalue('page')

if not page and os.path.exists( file ):
 # it is an html template
 page = file.replace( '/home/dauwin/public_html/', '' )
elif page or form.getvalue('show'):
 # it is a python script
 page = page..replace(
'/home/dauwin/public_html/cgi-__bin/', '' )
else:
 #when everything else fails fallback
 page = "index.html"




 if page.endswith('.html'):
 with open( '/home/dauwin/public_html/' + page,
encoding='utf-8' ) as f:
 htmlpage = f.read()
 htmlpage = htmlpage % (quote, music)
 template = htmlpage + counter
 elif page.endswith('.py'):
 pypage = subprocess.check_output(
'/home/dauwin/public_html/cgi-__bin/' + page )
 pypage = pypage.decode('utf-8').__replace(
'Content-type: text/html; charset=utf-8', '' )
 template = pypage + counter

 print( template )
[/code]

Everything as you see point to 'dauwin' username, yet the error
still says:

[code]
[Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173]   File
"/home/nikos/public_html/cgi-__bin/metrites.py", line 219, in
, referer: http://superhost.gr/
[Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173] with
open( '/home/nikos/public_html/' + page, encoding='utf-8' ) as f:,
referer: http://superhost.gr/
[Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173]
FileNotFoundError: [Errno 2] \\u0394\\u03b5\\u03bd
\\u03c5\\u03c0\\u03ac\\u03c1\\__u03c7\\u03b5\\u03b9
\\u03c4\\u03ad\\u03c4\\u03bf\\__u03b9\\u03bf
\\u03b1\\u03c1\\u03c7\\u03b5\\__u03af\\u03bf \\u03ae
\\u03ba\\u03b1\\u03c4\\u03ac\\__u03bb\\u03bf\\u03b3\\u03bf\\__u03c2:
'/home/nikos/public_html//__home/dauwin/public_html/index.__html',
referer: http://superhost.gr/
[/code]


Notice that you have the file path you want concatenated to your
/home/nikos/... stuff in the line above.  Look in your code to find out
why. Fix that.  Lather, rinse, repeat


In my source code as seen above i mention nowhere for '/home/nikos/' but
instead for '/home/dauwin/'

That error message makes me come to conclusion that metrites.py script
is running from user's nikos' cgi-bin:

/home/nikos/public_html/cgi-bin/metrites.py

instead of:

/home/dauwin/public_html/cgi-bin/metrites.py

I wonder why.
I mean iam sayign it clearly

with open( '/home/dauwin/public_html/' + page,

and the error says:

[Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173] with
 > open( '/home/nikos/public_html/' + page, encoding='utf-8' ) as f:,
 > referer: http://superhost.gr/

What happens when i give http://superhost.gr/~dauwin

Why home/nikos/public_html/cgi-bin/metrites.py seems to be the scritp
that always run?

That should have run when i browser: 'http://superhost.gr' and not when
i browse 'http://superhost.gr/~dauwin'

Please help. A client wanst to utilize my metrites.py script because he
lieks the way that has a seperate counter for each html page and the way
the log is presented in an html table like form.
Of course i will give it it to him for free.



Please suggest something of why this happnes.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Wrong website loaded when other requested

2013-06-13 Thread Chris Angelico
On Fri, Jun 14, 2013 at 12:23 AM, Νικόλαος Κούρας  wrote:
> Please suggest something of why this happnes.

You remind me of George.

http://www.chroniclesofgeorge.com/

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


Re: Turnign greek-iso filenames => utf-8 iso

2013-06-13 Thread Νικόλαος Κούρας

On 13/6/2013 9:49 πμ, Νικόλαος Κούρας wrote:

On 12/6/2013 1:40 μμ, Νικόλαος Κούρας wrote:

Thanks Steven , i made some alternations to the variables names and at
the end of the way that i check a database filename against and hdd
filename. Here is the code:

#
=


# Convert wrongly encoded filenames to utf-8
#
=


path = b'/home/nikos/public_html/data/apps/'
filenames = os.listdir( path )

utf8_filenames = []

for filename in filenames:
 # Compute 'path/to/filename'
 filename_bytes = path + filename
 encoding = guess_encoding( filename_bytes )

 if encoding == 'utf-8':
 # File name is valid UTF-8, so we can skip to the next file.
 utf8_filenames.append( filename_bytes )
 continue
 elif encoding is None:
 # No idea what the encoding is. Hit it with a hammer until it
stops moving.
 filename = filename_bytes.decode( 'utf-8', 'xmlcharrefreplace' )
 else:
 filename = filename_bytes.decode( encoding )

 # Rename the file to something which ought to be UTF-8 clean.
 newname_bytes = filename.encode('utf-8')
 os.rename( filename_bytes, newname_bytes )
 utf8_filenames.append( newname_bytes )

 # Once we get here, the file ought to be UTF-8 clean and the
Unicode name ought to exist:
 assert os.path.exists( newname_bytes.decode('utf-8') )


# Switch filenames from utf8 bytestrings => unicode strings
filenames = []

for utf8_filename in utf8_filenames:
 filenames.append( utf8_filename.decode('utf-8') )

# Check the presence of a database file against the dir files and delete
record if it doesn't exist
cur.execute('''SELECT url FROM files''')
data = cur.fetchall()

for url in data:
 if url not in filenames:
 # Delete spurious
 cur.execute('''DELETE FROM files WHERE url = %s''', url )
=

Now 'http://superhost.gr/?page=files.py' is not erring out at all but
also it doesn't display the big filename table for users to download.

Here is how i try to print the filenames with button for the users:

=


#Display ALL files, each with its own download button#
=


print('''
  
  
''')

try:
 cur.execute( '''SELECT * FROM files ORDER BY lastvisit DESC''' )
 data = cur.fetchall()

 for row in data:
 (filename, hits, host, lastvisit) = row
 lastvisit = lastvisit.strftime('%A %e %b, %H:%M')

 print('''
 
 

%s 
%s 
%s 
 
 
 ''' % (filename, hits, host, lastvisit) )
 print( '' )
except pymysql.ProgrammingError as e:
 print( repr(e) )


Steven, i can create a normal user account for you and copy files.py
into your home folder if you want to take a look from within.

Since the code seems correct, cause its not erring out and you 've
helped me write it, then i dont knwo what else to try.

Those files inside 'apps' dir ought to be printed in an html table fter
their utf-8 conversion.

They still insist not to...



Can you accept please? or suggest something i should try so for the 
files to be correctly viewed by my visitors?

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


Re: A certainl part of an if() structure never gets executed.

2013-06-13 Thread Νικόλαος Κούρας

On 13/6/2013 3:22 μμ, Sibylle Koczian wrote:

Am 13.06.2013 09:11, schrieb Νικόλαος Κούρας:

On 13/6/2013 4:55 πμ, Steven D'Aprano wrote:


The "and" operator works in a similar fashion. Experiment with it and
see
how it works for yourself.


I read yours psots many times,all of them, tryign to understand them.



But you didn't do what he recommended, did you? And it's really the best
or possibly the only way to understanding.

Try it out in the interactive Shell, using Stevens examples connected
with 'and' instead of 'or'.


I try and try to work it out but i can't understand it even in theory.

==

if '-' not in ( name and month and year ):
cur.execute( '''SELECT * FROM works WHERE clientsID = 
(SELECT id FROM clients WHERE name = %s) and MONTH(lastvisit) = %s and 
YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', (name, month, year) )

elif '-' not in ( name and year ):
cur.execute( '''SELECT * FROM works WHERE clientsID = 
(SELECT id FROM clients WHERE name = %s) and YEAR(lastvisit) = %s ORDER 
BY lastvisit ASC''', (name, year) )

elif '-' not in ( month and year ):
cur.execute( '''SELECT * FROM works WHERE MONTH(lastvisit) 
= %s and YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', (month, year) )

elif '-' not in year:
cur.execute( '''SELECT * FROM works WHERE YEAR(lastvisit) = 
%s ORDER BY lastvisit ASC''', year )


==

i just want 4 cases to examine so correct execute to be run:

i'm reading and reading and reading this all over:

if '-' not in ( name and month and year ):

and i cant comprehend it.

While it seems so beautiful saying:

if character '-' ain't contained in string name , neither in string 
month neither in string year.


But it just doesn't work like this.

Since  ( name and month and year ) are all truthy values, what is 
returned by this expression to be checked if it cotnains '=' within it?




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


Re: Wrong website loaded when other requested

2013-06-13 Thread Thomas Murphy
Chris,

I had never encountered George before today, and now my life is a little
bit better.

This and "help vampires" in one morning, today's shaping up well! (now if
this JSON would serialize with this #*@$ing angularJS Controller, but
that's for another list)


On Thu, Jun 13, 2013 at 10:28 AM, Chris Angelico  wrote:

> On Fri, Jun 14, 2013 at 12:23 AM, Νικόλαος Κούρας 
> wrote:
> > Please suggest something of why this happnes.
>
> You remind me of George.
>
> http://www.chroniclesofgeorge.com/
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Sincerely,
Thomas Murphy
Code Ninja
646.957.6115
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A certainl part of an if() structure never gets executed.

2013-06-13 Thread Νικόλαος Κούρας

On 13/6/2013 12:16 πμ, Sibylle Koczian wrote:

Am 12.06.2013 22:00, schrieb Νικόλαος Κούρας:

On 12/6/2013 10:48 μμ, Sibylle Koczian wrote:

if '=' not in ( name and month and year ):
i understand: if '=' not in name AND '=' not in month AND '=' not in
year


Wrong. The "'=' not in (...)" first evaluates the expression in
parentheses, that's what parentheses are for. And then it looks for '='
in the result. And that result is just one of the three values, MRAB
told you which one.


okey first the expression eval:

( name and month and year ) = ( name=True and month=True and year=True )


No. Read MRABs post, he explains it. Or work through the tutorial. This
would be right in another language, but not in Python.

If this expression would really evaluate to True or False, you
definitely couldn't search for any character in the result.

As it is, it evaluates to a string or to None, but searching for '=' in
that string doesn't give the result you think it does.


(name and month and year) is a Boolean expression, correct?

It will return True if all three are True and False otherwise. I cannot 
use it the way i desire regardless of how logical i think it looks.


Basically its just like i'am saying:


if "-" in True:
or
if "-" in False:

Obviously when i write it this way you can see it makes no sense.

==
But (name or month or year) is also a Boolean expression.

It will return the first of the three depending which value comes first 
as truthy.

it will return False if none of the three are False.

So how am i going to write it that?

if '-' not in name and '-' not in month and '-' not in year:  ??


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


Re: Wrong website loaded when other requested

2013-06-13 Thread Andreas Perstinger

On 13.06.2013 16:23, Νικόλαος Κούρας wrote:

Please suggest something of why this happnes.


That's not a Python problem.

BTW both scripts at
http://superhost.gr/~dauwin/metrites.py
and at
http://superhost.gr/~dauwin/cgi-bin/metrites.py
show the world the passwords to your databases in plain text.

Bye, Andreas
--
http://mail.python.org/mailman/listinfo/python-list


Re: Performance of list.index - how to speed up a silly algorithm?

2013-06-13 Thread Onyxx
I would convert your list to a  pandas dataframe.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wrong website loaded when other requested

2013-06-13 Thread Chris Angelico
On Fri, Jun 14, 2013 at 12:54 AM, Andreas Perstinger
 wrote:
> On 13.06.2013 16:23, Νικόλαος Κούρας wrote:
>>
>> Please suggest something of why this happnes.
>
>
> That's not a Python problem.
>
> BTW both scripts at
> http://superhost.gr/~dauwin/metrites.py
> and at
> http://superhost.gr/~dauwin/cgi-bin/metrites.py
> show the world the passwords to your databases in plain text.

See, that's the kind of thing that means you can't give out even
read-only access to your server. Does this mean anything to you Nikos?

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


Re: Turnign greek-iso filenames => utf-8 iso

2013-06-13 Thread Zero Piraeus
:

> Steven, i can create a normal user account for you and copy files.py into
> your home folder if you want to take a look from within.

Nikos, please, DO NOT DO THIS.

It must be clear to you that Steven is *much* more experienced than
you. Your presumptions about what he can and can't do with the access
you give him are therefore not much more than uninformed guesswork.

You have already been give a lesson about trusting the care of your
(and by extension your clients) resources to people you don't know,
and Chris, who gave you that lesson, is telling you that the course of
action you propose is unwise.

Steven has given every impression, over a long period, of being one of
the good guys, but *you don't know him*, and *you don't have any kind
of legal agreement with him* that would protect you should he turn out
to be malicious[1].

Given what's already happened to you, it would be the height of
irresponsibility to continue as you propose. If I were one of your
clients and I found out about it, I'd be seriously considering legal
action against you for gross negligence.

 -[]z.

[1] Steven, I don't intend any insinuations about your character, as
I'm sure you realise.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Turnign greek-iso filenames => utf-8 iso

2013-06-13 Thread Chris Angelico
On Thu, Jun 13, 2013 at 7:43 PM, Νικόλαος Κούρας  wrote:
> On 13/6/2013 12:25 μμ, Chris Angelico wrote:
>>
>> On Thu, Jun 13, 2013 at 6:15 PM,  �� 
>> wrote:
>>>
>>> I host no "e-shop" websites, hence into my system there is no credit card
>>> info stored, no id photos, no SSN, nothing.
>>>
>>> Now i checked and most are Joomla files or sites made by DreamWeaver.
>>> and they are 755, that would mean group and word readable, *not*
>>> writable,
>>> so no harm can possibly come out of this.
>>
>>
>> You really want to bet everything that not one of your clients has a
>> single bit of private information? Have you really learned nothing?
>
>
> Yes i can take that bet. All of clients ar also good friends and i know
> their websites and what they are storing, nothing else that each website
> representation, nothing personal.

So you'd be okay with publishing their mail directories, their contact
emails, and everything else they have in their home directories?

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


Re: Problem creating a regular expression to parse open-iscsi, iscsiadm output (help?)

2013-06-13 Thread Kevin LaTona

On Jun 12, 2013, at 5:59 PM, rice.cr...@gmail.com wrote:


> I am parsing the output of an open-iscsi command that contains several blocks 
> of data for each data set. Each block has the format:
>  Lastly, a version of this regex as a non-VERBOSE expression works as 
> expected.. Something about re.VERBOSE... 
Snip


With the following code tweaks in Python 2.7.2, I find it works with VERBOSE 
for me, but not without.

I would say the regex could still use some more adjustments yet.

-Kevin





import re

inp ="""
Target: iqn.1992-04.com.emc:vplex-8460319f-0007
   Current Portal: 221.128.52.224:3260,7
   Persistent Portal: 221.128.52.224:3260,7
   **
   Interface:
   **
   Iface Name: default
   Iface Transport: tcp
   Iface Initiatorname: iqn.1996-04.de.suse:01:7c9741b545b5
   Iface IPaddress: 221.128.52.214
   Iface HWaddress: 
   Iface Netdev: 
   SID: 154
   iSCSI Connection State: LOGGED IN
   iSCSI Session State: LOGGED_IN
   Internal iscsid Session State: NO CHANGE
"""

regex = re.compile( r'''
 # Target name, iqn
  Target:\s+(?P\S+)\s*
  # Target portal
  \s+Current\sPortal:\s*
  (?P\w+\.\w+\.\w+\.\w+):(?P\d+),(?P\d+)
  # skip lines...
  [\s\S]*?
  # Initiator name, iqn
  Iface\s+Initiatorname:\s+(?P\S+)\s*
  # Initiator port, IP address
  Iface\s+IPaddress:\s+(?P\S+)
  # skip lines...
  [\s\S]*?
  # Session ID
  SID:\s+(?P\d+)\s*
  # Connection state
  iSCSI\ +Connection\ +State:\s+(?P\w+\s*\w*)
  [\s\S]*?
  # Session state iSCSI
  iSCSI\s+Session\s+State:\s+(?P\w+)\s*
  # Session state Internal
  Internal\s+iscsid\s+Session\s+State:.*\s+(?P\w+\s\w+)
   ''', re.VERBOSE|re.MULTILINE)

myDetails = [ m.groupdict() for m in regex.finditer(inp)][0]
for k,v in myDetails.iteritems():
   print k,v




#*

If you want just the values back in the order parsed this will work for now.


for match in regex.findall(inp):
  for item in range(len(match)):
print match[item]



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


Re: Wrong website loaded when other requested

2013-06-13 Thread Joel Goldstick
So Nick, I am top posting because I don't think you read your replies.  I
replied yesterday.

Read this line below.  Read the line below.  READ it.  READ IT.. each
letter.  READ it:

[Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173]
FileNotFoundError: [Errno 2] \\u0394\\u03b5\\u03bd
\\u03c5\\u03c0\\u03ac\\u03c1\\
>
> u03c7\\u03b5\\u03b9 \\u03c4\\u03ad\\u03c4\\u03bf\\u03b9\\u03bf
> \\u03b1\\u03c1\\u03c7\\u03b5\\u03af\\u03bf \\u03ae
> \\u03ba\\u03b1\\u03c4\\u03ac\\u03bb\\u03bf\\u03b3\\u03bf\\u03c2:
> '/home/nikos/public_html//home/dauwin/public_html/index.html', referer:
> http://superhost.gr/
> [/code]
>
DO YOU SEE THIS PART:
 '/home/nikos/public_html//home/dauwin/public_html/index.html', referer:
http://superhost.gr/

Do you see that it prepends your nikos path the your dauwin path and file
name.  It isn't replacing one with the other.  Somewhere in your SFBI mess
of code you perhaps have set the nikos path as the start of a filename.
Check that out


DID YOU READ THIS?  DID YOU THINK ABOUT IT.  Also look up SFBI.  It is a
good name for you

> [/code]
>



On Wed, Jun 12, 2013 at 4:35 PM, Joel Goldstick wrote:

>
>
>
> On Wed, Jun 12, 2013 at 1:33 PM, Νικόλαος Κούρας wrote:
>
>> ==
>> RewriteEngine Off
>> RewriteCond %{REQUEST_FILENAME} -f
>> RewriteRule ^/?(.+\.html) /cgi-bin/metrites.py?file=%{**REQUEST_FILENAME}
>> [L,PT,QSA]
>> ==
>>
>> [code]
>> file = form.getvalue('file')
>> page = form.getvalue('page')
>>
>> if not page and os.path.exists( file ):
>> # it is an html template
>> page = file.replace( '/home/dauwin/public_html/', '' )
>> elif page or form.getvalue('show'):
>> # it is a python script
>> page = page..replace( '/home/dauwin/public_html/cgi-**bin/', '' )
>> else:
>> #when everything else fails fallback
>> page = "index.html"
>>
>> 
>> 
>>
>> if page.endswith('.html'):
>> with open( '/home/dauwin/public_html/' + page,
>> encoding='utf-8' ) as f:
>> htmlpage = f.read()
>> htmlpage = htmlpage % (quote, music)
>> template = htmlpage + counter
>> elif page.endswith('.py'):
>> pypage = subprocess.check_output(
>> '/home/dauwin/public_html/cgi-**bin/' + page )
>> pypage = pypage.decode('utf-8').**replace(
>> 'Content-type: text/html; charset=utf-8', '' )
>> template = pypage + counter
>>
>> print( template )
>> [/code]
>>
>> Everything as you see point to 'dauwin' username, yet the error still
>> says:
>>
>> [code]
>> [Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173]   File
>> "/home/nikos/public_html/cgi-**bin/metrites.py", line 219, in ,
>> referer: http://superhost.gr/
>> [Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173] with open(
>> '/home/nikos/public_html/' + page, encoding='utf-8' ) as f:, referer:
>> http://superhost.gr/
>> [Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173]
>> FileNotFoundError: [Errno 2] \\u0394\\u03b5\\u03bd
>> \\u03c5\\u03c0\\u03ac\\u03c1\\**u03c7\\u03b5\\u03b9
>> \\u03c4\\u03ad\\u03c4\\u03bf\\**u03b9\\u03bf
>> \\u03b1\\u03c1\\u03c7\\u03b5\\**u03af\\u03bf \\u03ae
>> \\u03ba\\u03b1\\u03c4\\u03ac\\**u03bb\\u03bf\\u03b3\\u03bf\\**u03c2:
>> '/home/nikos/public_html//**home/dauwin/public_html/index.**html',
>> referer: http://superhost.gr/
>> [/code]
>>
>>
>> Notice that you have the file path you want concatenated to your
> /home/nikos/... stuff in the line above.  Look in your code to find out
> why. Fix that.  Lather, rinse, repeat
>
>> Why is pointing to /home/nikos isntead of /home/dauwin ?
>>
>> this is what a smash my head to the wall to understand.
>> --
>> http://mail.python.org/**mailman/listinfo/python-list
>>
>
>
>
> --
> Joel Goldstick
> http://joelgoldstick.com
>



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Performance of list.index - how to speed up a silly algorithm?

2013-06-13 Thread Dave Angel

On 06/13/2013 10:55 AM, Onyxx wrote:

I would convert your list to a  pandas dataframe.



You're leaving a message on a public forum without any context in the 
message, using a title that was apparently last used in 2010.


Are you really trying to reply to a message from over 3 years ago???

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


Re: My son wants me to teach him Python

2013-06-13 Thread Tomasz Rola
On Thu, 13 Jun 2013, rusi wrote:

> On Jun 13, 12:46 am, John Ladasky  wrote:
> > Hi folks,
> >
> > My son is 17 years old.  He just took a one-year course in web page 
> > design at his high school.  HTML is worth knowing, I suppose, and I 
> > think he has also done a little Javascript.  He has expressed an 
> > interest in eventually wanting to program 3D video games.
[...]
> 
> Some views of mine (controversial!).

Not really :-)

> 
> Python is at least two things, a language and a culture.
> As a language its exceptionally dogma-neutral.
> You can do OO or FP, throwaway one-off scripts or long-term system
> building etc
> 
> However as a culture it seems to prefer the OO style to the FP style.
> This is unfortunate given that OO is on the down and FP is on a rise.
> Some thoughts re OOP: 
> http://blog.languager.org/2012/07/we-dont-need-no-o-orientation-4.html
> 
> So my suggestion is use some rigorous FPL like Haskell to learn/teach
> programming.
> After that you can switch to python or some other realistic language.

If he (son) learns Haskell, he may as well stay with it, because it's 
quite decent lang as far as I can tell. And it's compiled, too.

I would also consider Racket, which is a Scheme superset. It too, comes 
with compiler/JIT, plus IDE, plus libraries plus I understand examples 
from "Structure and Interpretation of Computer Programs", 
( http://mitpress.mit.edu/sicp/ ) can be run on it. I have heard some 
folks are doing real life stuff with it, too and IDE might help beginner a 
lot (this one is very nice, not just magnified editor).

> Note: I have some serious reservations regarding Haskell
> http://blog.languager.org/2012/08/functional-programming-philosophical.html
> Nevertheless it seems to be the best there is at the moment.

Mee too! For this reason I am exploring Ocaml and SML.

Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
** **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Turnign greek-iso filenames => utf-8 iso

2013-06-13 Thread Νικόλαος Κούρας

On 13/6/2013 5:16 μμ, Zero Piraeus wrote:

:


Steven, i can create a normal user account for you and copy files.py into
your home folder if you want to take a look from within.


Nikos, please, DO NOT DO THIS.

It must be clear to you that Steven is *much* more experienced than
you. Your presumptions about what he can and can't do with the access
you give him are therefore not much more than uninformed guesswork.


But iam not offering Steven full root access, but restricted user level 
access. Are you implying that for example one could elevate his 
privileges to root level access form within a normal restricted user 
account?



You have already been give a lesson about trusting the care of your
(and by extension your clients) resources to people you don't know,
and Chris, who gave you that lesson, is telling you that the course of
action you propose is unwise.

Steven has given every impression, over a long period, of being one of
the good guys, but *you don't know him*, and *you don't have any kind
of legal agreement with him* that would protect you should he turn out
to be malicious[1].


He is the only one helping me so far, to my hundreds of questiosn and in 
detail. He also the only one that didn't made fun of me because being 
inexperienced by making funny jokes at my expense.


I trust him.

Also there is no other way of me solving this, so i have no other 
alternative and i *must* solve this its over 15 days i'am trying with 
this encoding issues, let alone years of trouble in various other scripts.



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


Re: Wrong website loaded when other requested

2013-06-13 Thread Νικόλαος Κούρας

On 13/6/2013 5:54 μμ, Andreas Perstinger wrote:


That's not a Python problem.

BTW both scripts at
http://superhost.gr/~dauwin/metrites.py
and at
http://superhost.gr/~dauwin/cgi-bin/metrites.py
show the world the passwords to your databases in plain text.


Oh my God, i'll find an httpd.conf directive ot .htaccess directive that 
prohibits display of source code of cgi scripts


please tell me if you know of such a directive.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Wrong website loaded when other requested

2013-06-13 Thread Chris Angelico
On Fri, Jun 14, 2013 at 2:23 AM, Νικόλαος Κούρας  wrote:
> Oh my God, i'll find an httpd.conf directive ot .htaccess directive that
> prohibits display of source code of cgi scripts
>
> please tell me if you know of such a directive.

Yes. This will majorly improve your security. It goes in your
httpd.conf or equivalent.

Listen 127.0.0.1:80

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


Re: Wrong website loaded when other requested

2013-06-13 Thread Νικόλαος Κούρας

On 13/6/2013 6:11 μμ, Chris Angelico wrote:

On Fri, Jun 14, 2013 at 12:54 AM, Andreas Perstinger
 wrote:

On 13.06.2013 16:23,  �� wrote:


Please suggest something of why this happnes.



That's not a Python problem.

BTW both scripts at
http://superhost.gr/~dauwin/metrites.py
and at
http://superhost.gr/~dauwin/cgi-bin/metrites.py
show the world the passwords to your databases in plain text.


See, that's the kind of thing that means you can't give out even
read-only access to your server. Does this mean anything to you Nikos?

ChrisA


Yes it does iam researchign a solution to this as we speak.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Wrong website loaded when other requested

2013-06-13 Thread rusi
On Jun 13, 7:28 pm, Chris Angelico  wrote:
> On Fri, Jun 14, 2013 at 12:23 AM, Íéêüëáïò Êïýñáò  
> wrote:
> > Please suggest something of why this happnes.
>
> You remind me of George.
>
> http://www.chroniclesofgeorge.com/
>
> ChrisA

HA!
You are evil -- Chris!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wrong website loaded when other requested

2013-06-13 Thread Νικόλαος Κούρας

On 13/6/2013 6:35 μμ, Joel Goldstick wrote:

[Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173]
FileNotFoundError: [Errno 2] \\u0394\\u03b5\\u03bd
\\u03c5\\u03c0\\u03ac\\u03c1\\

u03c7\\u03b5\\u03b9 \\u03c4\\u03ad\\u03c4\\u03bf\\u03b9\\u03bf
\\u03b1\\u03c1\\u03c7\\u03b5\\u03af\\u03bf \\u03ae
\\u03ba\\u03b1\\u03c4\\u03ac\\u03bb\\u03bf\\u03b3\\u03bf\\u03c2:
'/home/nikos/public_html//home/dauwin/public_html/index.html',
referer: http://superhost.gr/
[/code]

DO YOU SEE THIS PART:
  '/home/nikos/public_html//home/dauwin/public_html/index.html',
referer: http://superhost.gr/

Do you see that it prepends your nikos path the your dauwin path and
file name.  It isn't replacing one with the other.  Somewhere in your
SFBI mess of code you perhaps have set the nikos path as the start of a
filename.  Check that out


yes i saw your post Joel,

After research i am under the impression that i'am in need for UserDir 
directive as it essentially allows you to use User Home directories as 
web directories...


So after reading this: 
http://centosforge.com/node/how-get-userdir-user-specific-publichtml-working-apache-centos-6

i did this:



UserDir public_html


#UserDir disabled
UserDir "enabled *"
UserDir "disabled root"




root@nikos [~]# chmod 711 /home
root@nikos [~]# chmod 711 /home/nikos
root@nikos [~]# chmod 755 /home/nikos/public_html/
root@nikos [~]# chmod o+r /home/nikos/public_html/index.html
root@nikos [~]# chmod 711 /home/dauwin
root@nikos [~]# chmod 755 /home/dauwin/public_html/
root@nikos [~]# chmod o+r /home/dauwin/public_html/index.html
root@nikos [~]#

setsebool -P httpd_enable_homedirs true
chcon -R -t httpd_sys_content_t /home/testuser/public_html
(the last one one failed though)

the i restarted Apache but the problem is still there.

===
ni...@superhost.gr [~]# [Thu Jun 13 19:50:57 2013] [error] [client 
79.103.41.173] Error in sys.excepthook:
[Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] ValueError: 
underlying buffer has been detached

[Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173]
[Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] Original 
exception was:
[Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] Traceback 
(most recent call last):
[Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173]   File 
"/home/nikos/public_html/cgi-bin/metrites.py", line 213, in 
[Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] with open( 
'/home/nikos/public_html/' + page, encoding='utf-8' ) as f:
[Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] 
FileNotFoundError: [Errno 2] \\u0394\\u03b5\\u03bd 
\\u03c5\\u03c0\\u03ac\\u03c1\\u03c7\\u03b5\\u03b9 
\\u03c4\\u03ad\\u03c4\\u03bf\\u03b9\\u03bf 
\\u03b1\\u03c1\\u03c7\\u03b5\\u03af\\u03bf \\u03ae 
\\u03ba\\u03b1\\u03c4\\u03ac\\u03bb\\u03bf\\u03b3\\u03bf\\u03c2: 
'/home/nikos/public_html//home/dauwin/public_html/index.html'



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


Re: A certainl part of an if() structure never gets executed.

2013-06-13 Thread Νικόλαος Κούρας

if '-' not in name + month + year:
			cur.execute( '''SELECT * FROM works WHERE clientsID = (SELECT id FROM 
clients WHERE name = %s) and MONTH(lastvisit) = %s and YEAR(lastvisit) = 
%s ORDER BY lastvisit ASC''', (name, month, year) )

elif '-' not in name + year:
			cur.execute( '''SELECT * FROM works WHERE clientsID = (SELECT id FROM 
clients WHERE name = %s) and YEAR(lastvisit) = %s ORDER BY lastvisit 
ASC''', (name, year) )

elif '-' not in month + year:
			cur.execute( '''SELECT * FROM works WHERE MONTH(lastvisit) = %s and 
YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', (month, year) )

elif '-' not in year:
			cur.execute( '''SELECT * FROM works WHERE YEAR(lastvisit) = %s ORDER 
BY lastvisit ASC''', year )



This finally worked!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Wrong website loaded when other requested

2013-06-13 Thread Νικόλαος Κούρας

On 13/6/2013 7:28 μμ, Chris Angelico wrote:

On Fri, Jun 14, 2013 at 2:23 AM,  ��  wrote:

Oh my God, i'll find an httpd.conf directive ot .htaccess directive that
prohibits display of source code of cgi scripts

please tell me if you know of such a directive.


Yes. This will majorly improve your security. It goes in your
httpd.conf or equivalent.

Listen 127.0.0.1:80

ChrisA


liek iam gonna fall for that!!!

127.0.0.1 is listening only to itself :)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Version Control Software

2013-06-13 Thread Grant Edwards
On 2013-06-13, Ben Finney  wrote:
> cutems93  writes:
>
>> I am looking for an appropriate version control software for python
>> development, and need professionals' help to make a good decision.
>
>> Currently I am considering four software: git, SVN, CVS, and
>> Mercurial.
>
> These days there is no good reason to use CVS nor Subversion for new
> projects. They are not distributed (the D in DVCS), and they have
> specific design flaws that often cause insidious problems with common
> version control workflows. As a salient example, branching and merging
> are so painful with these tools that many users have learned the
> terrible habit of never doing it at all.

I agree that branch/merge handling in svn is primitive compared to git
(haven't used hg enough to comment).

The last time we made the choice (4-5 years ago), Windows support for
get, bzr, and hg was definitely lacking compared to svn.  The lack of
something like tortoisesvn for hg/git/bzr was a killer.  It looks like
the situation has improved since then, but I'd be curious to hear from
people who do their development on Windows.

-- 
Grant Edwards   grant.b.edwardsYow! I wonder if there's
  at   anything GOOD on tonight?
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Turnign greek-iso filenames => utf-8 iso

2013-06-13 Thread Grant Edwards
On 2013-06-13,    wrote:
> On 13/6/2013 5:16 , Zero Piraeus wrote:
>> :
>>
>>> Steven, i can create a normal user account for you and copy files.py into
>>> your home folder if you want to take a look from within.
>>
>> Nikos, please, DO NOT DO THIS.
>>
>> It must be clear to you that Steven is *much* more experienced than
>> you. Your presumptions about what he can and can't do with the access
>> you give him are therefore not much more than uninformed guesswork.
>
> But iam not offering Steven full root access, but restricted user
> level access.

That's what you _think_ you're offering.

Unless you're are a very careful, very experienced system admin -- and
you're also lucky -- you're probably wrong.  If not now, then you'll
be wrong next week or next month when a new privelege elevation
exploit is discovered for your OS.

> Are you implying that for example one could elevate his privileges to
> root level access form within a normal restricted user account?

Yes, that's what he's implying.

-- 
Grant Edwards   grant.b.edwardsYow! I'm thinking about
  at   DIGITAL READ-OUT systems
  gmail.comand computer-generated
   IMAGE FORMATIONS ...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My son wants me to teach him Python

2013-06-13 Thread Tomasz Rola

I've reposted on another list and got this reply. At first I was sceptic 
a bit, but for the sake of completeness, here goes. Processing language 
seems to be interesting in its own right. Examples are Java-flavoured, 
images are ok.

Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
** **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **

-- Forwarded message --
Date: Thu, 13 Jun 2013 16:55:11 +0200
From: Eugen Leitl 
To:  
Subject: Re: [info] (comp.lang.python) Re: My son wants me to teach him Python

On Thu, Jun 13, 2013 at 04:48:52PM +0200, Tomasz Rola wrote:

> No. Definitely not. Programming does NOT begin with a GUI. It begins with 
> something *simple*, so you're not stuck fiddling around with the 
> unnecessary. On today's computers, that usually means console I/O 
> (actually console output, with console input coming along much later).

Of course kids are more interesting in things painted on
screen, especially if they are colorful, move and make
sounds at that. The next step would be a simple, 
interactive game.

Which is why I would synthesize something neat yet
simple from http://processing.org/tutorials/

Python is overkill for a kid. Ugh. Some people have just
no common sense at all.
___
info mailing list
i...@postbiota.org
http://postbiota.org/mailman/listinfo/info
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Turnign greek-iso filenames => utf-8 iso

2013-06-13 Thread Zero Piraeus
:

> But iam not offering Steven full root access, but restricted user level
> access. Are you implying that for example one could elevate his privileges
> to root level access form within a normal restricted user account?

I am implying that your demonstrated lack of ability means that *you
don't know* what Steven or anyone else could do with user-level
access. Elsewhere on this list, you've been shown that you're
publishing database passwords to the whole world in plaintext. Who
knows what other mistakes you've made? Who knows how
$STRANGER_YOU_TRUST_THIS_WEEK could exploit your (proven to be
insecure) setup if they had a mind to?

> I trust him.

And you have presumably informed all your clients that you're letting
the second complete stranger in a week into their data, passed on to
them the warnings you have received against doing exactly that,
reminded them that the last time you did so you were severely
embarrassed by the result (and that you're not skilled or experienced
enough to be sure that nothing worse happened), and secured their
go-ahead, right?

> Also there is no other way of me solving this, so i have no other
> alternative and i *must* solve this its over 15 days i'am trying with this
> encoding issues, let alone years of trouble in various other scripts.

Then you need to contract with paid, professional support to solve
your problems.

 -[]z.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My son wants me to teach him Python

2013-06-13 Thread Paul Rubin
Tomasz Rola  writes:
> I've reposted on another list and got this reply. At first I was sceptic 
> a bit, but for the sake of completeness, here goes. Processing language 
> seems to be interesting in its own right. Examples are Java-flavoured, 
> images are ok.

There is a book "Python for Kids" that I haven't looked at, from No
Starch Press.  You might check into it.

You might also look at the game Code Hero, which teaches kids to program
games with Unity3D and Javascript.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My son wants me to teach him Python

2013-06-13 Thread Mark Janssen
> Despite not want to RTFM as you say, you might set him in front of
> VPython, type

I totally forgot PyGame -- another likely source of self-motivated
learning for a teen programmer.
-- 
MarkJ
Tacoma, Washington
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My son wants me to teach him Python

2013-06-13 Thread rusi
On Jun 13, 9:50 pm, Tomasz Rola  wrote:
> I've reposted on another list and got this reply. At first I was sceptic
> a bit, but for the sake of completeness, here goes. Processing language
> seems to be interesting in its own right. Examples are Java-flavoured,
> images are ok.
>
> Regards,
> Tomasz Rola
>
> --
> ** A C programmer asked whether computer had Buddha's nature.      **
> ** As the answer, master did "rm -rif" on the programmer's home    **
> ** directory. And then the C programmer became enlightened...      **
> **                                                                 **
> ** Tomasz Rola          mailto:tomasz_r...@bigfoot.com             **
>
> -- Forwarded message --
> Date: Thu, 13 Jun 2013 16:55:11 +0200
> From: Eugen Leitl 
> To:  
> Subject: Re: [info] (comp.lang.python) Re: My son wants me to teach him Python
>
> On Thu, Jun 13, 2013 at 04:48:52PM +0200, Tomasz Rola wrote:
>
> > No. Definitely not. Programming does NOT begin with a GUI. It begins with
> > something *simple*, so you're not stuck fiddling around with the
> > unnecessary. On today's computers, that usually means console I/O
> > (actually console output, with console input coming along much later).
>
> Of course kids are more interesting in things painted on
> screen, especially if they are colorful, move and make
> sounds at that. The next step would be a simple,
> interactive game.
>
> Which is why I would synthesize something neat yet
> simple fromhttp://processing.org/tutorials/
>
> Python is overkill for a kid. Ugh. Some people have just
> no common sense at all.

All kids can be fit into the stereotype -- 'kid'??

I can tell you after 25 years teaching programming --
Some kids will take to FP, others will not
Some will take to C, some wont
Some will take to C AND C++, some will take to only one
The majority are ok with python, some hate it

One of my long term projects is to take a type classification like
http://en.wikipedia.org/wiki/Myers-Briggs_Type_Indicator
and see how it maps to a person's potential as a programmer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Turnign greek-iso filenames => utf-8 iso

2013-06-13 Thread Νικόλαος Κούρας

On 13/6/2013 8:27 μμ, Zero Piraeus wrote:

:


But iam not offering Steven full root access, but restricted user level
access. Are you implying that for example one could elevate his privileges
to root level access form within a normal restricted user account?


I am implying that your demonstrated lack of ability means that *you
don't know* what Steven or anyone else could do with user-level
access. Elsewhere on this list, you've been shown that you're
publishing database passwords to the whole world in plaintext. Who
knows what other mistakes you've made? Who knows how
$STRANGER_YOU_TRUST_THIS_WEEK could exploit your (proven to be
insecure) setup if they had a mind to?


I trust him.


You are right, but i still believe Stevn would not act maliciously in 
the server.  He proved himself very helpfull already.




Also there is no other way of me solving this, so i have no other
alternative and i *must* solve this its over 15 days i'am trying with this
encoding issues, let alone years of trouble in various other scripts.


Then you need to contract with paid, professional support to solve
your problems.


Or receive some free help, to solve this single detail i'am missing.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Turnign greek-iso filenames => utf-8 iso

2013-06-13 Thread Grant Edwards
On 2013-06-13,    wrote:
> On 13/6/2013 8:27 , Zero Piraeus wrote:
>
>> Then you need to contract with paid, professional support to solve
>> your problems.
>
> Or receive some free help, to solve this single detail i'am missing.

  "single detail I am missing"

Seriously?

-- 
Grant Edwards   grant.b.edwardsYow! What I want to find
  at   out is -- do parrots know
  gmail.commuch about Astro-Turf?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wrong website loaded when other requested

2013-06-13 Thread Νικόλαος Κούρας
Τη Πέμπτη, 13 Ιουνίου 2013 7:52:27 μ.μ. UTC+3, ο χρήστης Νικόλαος Κούρας έγραψε:
> On 13/6/2013 6:35 μμ, Joel Goldstick wrote:
> 
> > [Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173]
> 
> > FileNotFoundError: [Errno 2] \\u0394\\u03b5\\u03bd
> 
> > \\u03c5\\u03c0\\u03ac\\u03c1\\
> 
> >
> 
> > u03c7\\u03b5\\u03b9 \\u03c4\\u03ad\\u03c4\\u03bf\\u03b9\\u03bf
> 
> > \\u03b1\\u03c1\\u03c7\\u03b5\\u03af\\u03bf \\u03ae
> 
> > \\u03ba\\u03b1\\u03c4\\u03ac\\u03bb\\u03bf\\u03b3\\u03bf\\u03c2:
> 
> > '/home/nikos/public_html//home/dauwin/public_html/index.html',
> 
> > referer: http://superhost.gr/
> 
> > [/code]
> 
> >
> 
> > DO YOU SEE THIS PART:
> 
> >   '/home/nikos/public_html//home/dauwin/public_html/index.html',
> 
> > referer: http://superhost.gr/
> 
> >
> 
> > Do you see that it prepends your nikos path the your dauwin path and
> 
> > file name.  It isn't replacing one with the other.  Somewhere in your
> 
> > SFBI mess of code you perhaps have set the nikos path as the start of a
> 
> > filename.  Check that out
> 
> 
> 
> yes i saw your post Joel,
> 
> 
> 
> After research i am under the impression that i'am in need for UserDir 
> 
> directive as it essentially allows you to use User Home directories as 
> 
> web directories...
> 
> 
> 
> So after reading this: 
> 
> http://centosforge.com/node/how-get-userdir-user-specific-publichtml-working-apache-centos-6
> 
> i did this:
> 
> 
> 
> 
> 
> 
> 
> UserDir public_html
> 
> 
> 
> 
> 
> #UserDir disabled
> 
> UserDir "enabled *"
> 
> UserDir "disabled root"
> 
> 
> 
> 
> 
> 
> 
> 
> 
> root@nikos [~]# chmod 711 /home
> 
> root@nikos [~]# chmod 711 /home/nikos
> 
> root@nikos [~]# chmod 755 /home/nikos/public_html/
> 
> root@nikos [~]# chmod o+r /home/nikos/public_html/index.html
> 
> root@nikos [~]# chmod 711 /home/dauwin
> 
> root@nikos [~]# chmod 755 /home/dauwin/public_html/
> 
> root@nikos [~]# chmod o+r /home/dauwin/public_html/index.html
> 
> root@nikos [~]#
> 
> 
> 
> setsebool -P httpd_enable_homedirs true
> 
> chcon -R -t httpd_sys_content_t /home/testuser/public_html
> 
> (the last one one failed though)
> 
> 
> 
> the i restarted Apache but the problem is still there.
> 
> 
> 
> ===
> 
> ni...@superhost.gr [~]# [Thu Jun 13 19:50:57 2013] [error] [client 
> 
> 79.103.41.173] Error in sys.excepthook:
> 
> [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] ValueError: 
> 
> underlying buffer has been detached
> 
> [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173]
> 
> [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] Original 
> 
> exception was:
> 
> [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] Traceback 
> 
> (most recent call last):
> 
> [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173]   File 
> 
> "/home/nikos/public_html/cgi-bin/metrites.py", line 213, in 
> 
> [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] with open( 
> 
> '/home/nikos/public_html/' + page, encoding='utf-8' ) as f:
> 
> [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] 
> 
> FileNotFoundError: [Errno 2] \\u0394\\u03b5\\u03bd 
> 
> \\u03c5\\u03c0\\u03ac\\u03c1\\u03c7\\u03b5\\u03b9 
> 
> \\u03c4\\u03ad\\u03c4\\u03bf\\u03b9\\u03bf 
> 
> \\u03b1\\u03c1\\u03c7\\u03b5\\u03af\\u03bf \\u03ae 
> 
> \\u03ba\\u03b1\\u03c4\\u03ac\\u03bb\\u03bf\\u03b3\\u03bf\\u03c2: 
> 
> '/home/nikos/public_html//home/dauwin/public_html/index.html'
> 
> 

please take an overall look at my httpd.conf at http://pastebin.com/Pb3VbNC9 in 
case you want to examine somehting else. 

Thank you very much.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Debugging memory leaks

2013-06-13 Thread writeson
Dieter,

Thanks for the response, and you're correct, debugging memory leaks is tough! 
So far I haven't had much luck other than determining I have a leak. I've used 
objgraph to see that objects are being created that don't seem to get cleaned 
up. What I can't figure out so far is why, they are local variable objects that 
"should" get cleaned up when they go out scope.

Ah well, I'll keep pushing!
Thanks again,
Doug
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wrong website loaded when other requested

2013-06-13 Thread Nick the Gr33k



Τη Πέμπτη, 13 Ιουνίου 2013 7:52:27 μ.μ. UTC+3, ο χρήστης Νικόλαος Κούρας 
έγραψε:

> On 13/6/2013 6:35 μμ, Joel Goldstick wrote:
>
>> [Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173]
>
>> FileNotFoundError: [Errno 2] \\u0394\\u03b5\\u03bd
>
>> \\u03c5\\u03c0\\u03ac\\u03c1\\
>
>>
>
>> u03c7\\u03b5\\u03b9 \\u03c4\\u03ad\\u03c4\\u03bf\\u03b9\\u03bf
>
>> \\u03b1\\u03c1\\u03c7\\u03b5\\u03af\\u03bf \\u03ae
>
>> \\u03ba\\u03b1\\u03c4\\u03ac\\u03bb\\u03bf\\u03b3\\u03bf\\u03c2:
>
>> '/home/nikos/public_html//home/dauwin/public_html/index.html',
>
>> referer: http://superhost.gr/
>
>> [/code]
>
>>
>
>> DO YOU SEE THIS PART:
>
>>   '/home/nikos/public_html//home/dauwin/public_html/index.html',
>
>> referer: http://superhost.gr/
>
>>
>
>> Do you see that it prepends your nikos path the your dauwin path and
>
>> file name.  It isn't replacing one with the other.  Somewhere in your
>
>> SFBI mess of code you perhaps have set the nikos path as the start of a
>
>> filename.  Check that out
>
>
>
> yes i saw your post Joel,
>
>
>
> After research i am under the impression that i'am in need for UserDir
>
> directive as it essentially allows you to use User Home directories as
>
> web directories...
>
>
>
> So after reading this:
>
> 
http://centosforge.com/node/how-get-userdir-user-specific-publichtml-working-apache-centos-6

>
> i did this:
>
>
>
>
>
> 
>
> UserDir public_html
>
> 
>
> 
>
> #UserDir disabled
>
> UserDir "enabled *"
>
> UserDir "disabled root"
>
> 
>
>
>
>
>
>
>
> root@nikos [~]# chmod 711 /home
>
> root@nikos [~]# chmod 711 /home/nikos
>
> root@nikos [~]# chmod 755 /home/nikos/public_html/
>
> root@nikos [~]# chmod o+r /home/nikos/public_html/index.html
>
> root@nikos [~]# chmod 711 /home/dauwin
>
> root@nikos [~]# chmod 755 /home/dauwin/public_html/
>
> root@nikos [~]# chmod o+r /home/dauwin/public_html/index.html
>
> root@nikos [~]#
>
>
>
> setsebool -P httpd_enable_homedirs true
>
> chcon -R -t httpd_sys_content_t /home/testuser/public_html
>
> (the last one one failed though)
>
>
>
> the i restarted Apache but the problem is still there.
>
>
>
> ===
>
> ni...@superhost.gr [~]# [Thu Jun 13 19:50:57 2013] [error] [client
>
> 79.103.41.173] Error in sys.excepthook:
>
> [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] ValueError:
>
> underlying buffer has been detached
>
> [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173]
>
> [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] Original
>
> exception was:
>
> [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] Traceback
>
> (most recent call last):
>
> [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173]   File
>
> "/home/nikos/public_html/cgi-bin/metrites.py", line 213, in 
>
> [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] with open(
>
> '/home/nikos/public_html/' + page, encoding='utf-8' ) as f:
>
> [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173]
>
> FileNotFoundError: [Errno 2] \\u0394\\u03b5\\u03bd
>
> \\u03c5\\u03c0\\u03ac\\u03c1\\u03c7\\u03b5\\u03b9
>
> \\u03c4\\u03ad\\u03c4\\u03bf\\u03b9\\u03bf
>
> \\u03b1\\u03c1\\u03c7\\u03b5\\u03af\\u03bf \\u03ae
>
> \\u03ba\\u03b1\\u03c4\\u03ac\\u03bb\\u03bf\\u03b3\\u03bf\\u03c2:
>
> '/home/nikos/public_html//home/dauwin/public_html/index.html'
>
> 

please take an overall look at my httpd.conf at 
http://pastebin.com/Pb3VbNC9 in case you want to examine somehting else.


Thank you very much.


--
What is now proved was at first only imagined!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie: question regarding references and class relationships

2013-06-13 Thread Rui Maciel
Chris Angelico wrote:

> Just FYI, Rick Johnson (aka Ranting Rick) is a known troll. Don't let
> him goad you :)
> 
> Follow other people's advice, and take Rick's posts with a grain of
> salt. Sometimes he has a good point to make (more often when he's
> talking about tkinter, which is his area of expertise), but frequently
> he spouts rubbish.

I had no idea.  


Thanks for the headsup.
Rui Maciel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wrong website loaded when other requested

2013-06-13 Thread Joel Goldstick
On Thu, Jun 13, 2013 at 2:10 PM, Nick the Gr33k wrote:

>
>
> Τη Πέμπτη, 13 Ιουνίου 2013 7:52:27 μ.μ. UTC+3, ο χρήστης Νικόλαος Κούρας
> έγραψε:
> > On 13/6/2013 6:35 μμ, Joel Goldstick wrote:
> >
> >> [Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173]
> >
> >> FileNotFoundError: [Errno 2] \\u0394\\u03b5\\u03bd
> >
> >> \\u03c5\\u03c0\\u03ac\\u03c1\\
> >
> >>
> >
> >> u03c7\\u03b5\\u03b9 \\u03c4\\u03ad\\u03c4\\u03bf\\**u03b9\\u03bf
> >
> >> \\u03b1\\u03c1\\u03c7\\u03b5\\**u03af\\u03bf \\u03ae
> >
> >> \\u03ba\\u03b1\\u03c4\\u03ac\\**u03bb\\u03bf\\u03b3\\u03bf\\**
> u03c2:
> >
> >> '/home/nikos/public_html//**home/dauwin/public_html/index.**html',
> >
> >> referer: http://superhost.gr/
> >
> >> [/code]
> >
> >>
> >
> >> DO YOU SEE THIS PART:
> >
> >>   '/home/nikos/public_html//**home/dauwin/public_html/index.**html',
> >
> >> referer: http://superhost.gr/
> >
> >>
> >
> >> Do you see that it prepends your nikos path the your dauwin path and
> >
> >> file name.  It isn't replacing one with the other.  Somewhere in your
> >
> >> SFBI mess of code you perhaps have set the nikos path as the start of a
> >
> >> filename.  Check that out
> >
> >
> >
> > yes i saw your post Joel,
> >
> >
> >
> > After research i am under the impression that i'am in need for UserDir
> >
> > directive as it essentially allows you to use User Home directories as
> >
> > web directories...
> >
> >
> >
> > So after reading this:
> >
> > http://centosforge.com/node/**how-get-userdir-user-specific-**
> publichtml-working-apache-**centos-6
> >
> > i did this:
> >
> >
> >
> >
> >
> > 
> >
> > UserDir public_html
> >
> > 
> >
> > 
> >
> > #UserDir disabled
> >
> > UserDir "enabled *"
> >
> > UserDir "disabled root"
> >
> > 
> >
> >
> >
> >
> >
> >
> >
> > root@nikos [~]# chmod 711 /home
> >
> > root@nikos [~]# chmod 711 /home/nikos
> >
> > root@nikos [~]# chmod 755 /home/nikos/public_html/
> >
> > root@nikos [~]# chmod o+r /home/nikos/public_html/index.**html
> >
> > root@nikos [~]# chmod 711 /home/dauwin
> >
> > root@nikos [~]# chmod 755 /home/dauwin/public_html/
> >
> > root@nikos [~]# chmod o+r /home/dauwin/public_html/**index.html
> >
> > root@nikos [~]#
> >
> >
> >
> > setsebool -P httpd_enable_homedirs true
> >
> > chcon -R -t httpd_sys_content_t /home/testuser/public_html
> >
> > (the last one one failed though)
> >
> >
> >
> > the i restarted Apache but the problem is still there.
> >
> >
> >
> > ===
> >
> > ni...@superhost.gr [~]# [Thu Jun 13 19:50:57 2013] [error] [client
> >
> > 79.103.41.173] Error in sys.excepthook:
> >
> > [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] ValueError:
> >
> > underlying buffer has been detached
> >
> > [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173]
> >
> > [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] Original
> >
> > exception was:
> >
> > [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] Traceback
> >
> > (most recent call last):
> >
> > [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173]   File
>
> >
> > "/home/nikos/public_html/cgi-**bin/metrites.py", line 213, in 
> >
> > [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] with open(
>
> >
> > '/home/nikos/public_html/' + page, encoding='utf-8' ) as f:
> >
> > [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173]
>
> >
> > FileNotFoundError: [Errno 2] \\u0394\\u03b5\\u03bd
> >
> > \\u03c5\\u03c0\\u03ac\\u03c1\\**u03c7\\u03b5\\u03b9
> >
> > \\u03c4\\u03ad\\u03c4\\u03bf\\**u03b9\\u03bf
> >
> > \\u03b1\\u03c1\\u03c7\\u03b5\\**u03af\\u03bf \\u03ae
> >
> > \\u03ba\\u03b1\\u03c4\\u03ac\\**u03bb\\u03bf\\u03b3\\u03bf\\**u03c2:
> >
> > '/home/nikos/public_html//**home/dauwin/public_html/index.**html'
>

SECOND TIME:

I'm not an apache wizard, and I'm too self important to really look through
all of your code.  i don't getting germs.  But, once again:

your code is not finding a file named this:
 '/home/nikos/public_html//home/dauwin/public_html/index.html'

The first part of this file path is:'/home/nikos/public_html

After that are TWO forward slashes which remind me of http:// and following
that is the path you want.  so, you need to put new batteries in your
brain, look through your mess and figure out what creates the wrong file
name for you

> >
> > 
>
> please take an overall look at my httpd.conf at
> http://pastebin.com/Pb3VbNC9 in case you want to examine somehting else.
>
> Thank you very much.
>
>
> --
> What is now proved was at first only imagined!
> --
> http://mail.python.org/**mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wrong website loaded when other requested

2013-06-13 Thread Andreas Perstinger

On 13.06.2013 20:10, Nick the Gr33k wrote:
[nothing new]

Could you please stop spamming the whole internet with your problems.
Not only that you've posted two similar offtopic messages within only 6 
minutes to this list, you've also crossposted to alt.os.linux (where it 
is offtopic too) and to the forum at devshed.com (at least you've found 
the right subforum there).


Thank you very much!

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


Re: Any speech to text conversation python library for Linux and mac box

2013-06-13 Thread Miki Tebeka
On Wednesday, June 12, 2013 8:59:44 PM UTC-7, Ranjith Kumar wrote:
> I'm looking for speech to text conversation python library for linux and mac 
Not a Python library, but maybe you can work with 
http://cmusphinx.sourceforge.net/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Debugging memory leaks

2013-06-13 Thread Dave Angel

On 06/13/2013 02:07 PM, writeson wrote:

Dieter,

Thanks for the response, and you're correct, debugging memory leaks is tough! So far I 
haven't had much luck other than determining I have a leak. I've used objgraph to see 
that objects are being created that don't seem to get cleaned up. What I can't figure out 
so far is why, they are local variable objects that "should" get cleaned up 
when they go out scope.



Pure python code shouldn't have any leaks, but instead can have what I 
call stagnation.  That's data that's no longer useful, but the program 
has fooled the system into thinking it should hang onto it.


A leak happens in C code, when all the pointers to a given hunk of 
memory have gone away, and there's no way to access it any longer.


In pure Python, you don't work with pointers, but with references, and 
they are ref-counted.  When the count goes to zero, the object is freed. 
 Periodically a gc sweep happens, which catches those circular 
references which never actually go to zero.



So post a fragment of code that seems to cause the problem, and maybe 
someone can explain why.


1) objects with a __del__() method
2) objects that are "cached" by some mechanism
3) objects that collectively represent a lot of data
4) objects that are exposed to buggy C code


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


Re: Wrong website loaded when other requested

2013-06-13 Thread Nick the Gr33k

On 13/6/2013 9:28 μμ, Joel Goldstick wrote:




On Thu, Jun 13, 2013 at 2:10 PM, Nick the Gr33k mailto:supp...@superhost.gr>> wrote:



Τη Πέμπτη, 13 Ιουνίου 2013 7:52:27 μ.μ. UTC+3, ο χρήστης Νικόλαος
Κούρας έγραψε:
 > On 13/6/2013 6:35 μμ, Joel Goldstick wrote:
 >
 >> [Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173]
 >
 >> FileNotFoundError: [Errno 2] \\u0394\\u03b5\\u03bd
 >
 >> \\u03c5\\u03c0\\u03ac\\u03c1\\
 >
 >>
 >
 >> u03c7\\u03b5\\u03b9 \\u03c4\\u03ad\\u03c4\\u03bf\\__u03b9\\u03bf
 >
 >> \\u03b1\\u03c1\\u03c7\\u03b5\\__u03af\\u03bf \\u03ae
 >
 >>
\\u03ba\\u03b1\\u03c4\\u03ac\\__u03bb\\u03bf\\u03b3\\u03bf\\__u03c2:
 >
 >>
'/home/nikos/public_html//__home/dauwin/public_html/index.__html',
 >
 >> referer: http://superhost.gr/
 >
 >> [/code]
 >
 >>
 >
 >> DO YOU SEE THIS PART:
 >
 >>   '/home/nikos/public_html//__home/dauwin/public_html/index.__html',
 >
 >> referer: http://superhost.gr/
 >
 >>
 >
 >> Do you see that it prepends your nikos path the your dauwin path and
 >
 >> file name.  It isn't replacing one with the other.  Somewhere in
your
 >
 >> SFBI mess of code you perhaps have set the nikos path as the
start of a
 >
 >> filename.  Check that out
 >
 >
 >
 > yes i saw your post Joel,
 >
 >
 >
 > After research i am under the impression that i'am in need for
UserDir
 >
 > directive as it essentially allows you to use User Home
directories as
 >
 > web directories...
 >
 >
 >
 > So after reading this:
 >
 >

http://centosforge.com/node/__how-get-userdir-user-specific-__publichtml-working-apache-__centos-6


 >
 > i did this:
 >
 >
 >
 >
 >
 > 
 >
 > UserDir public_html
 >
 > 
 >
 > 
 >
 > #UserDir disabled
 >
 > UserDir "enabled *"
 >
 > UserDir "disabled root"
 >
 > 
 >
 >
 >
 >
 >
 >
 >
 > root@nikos [~]# chmod 711 /home
 >
 > root@nikos [~]# chmod 711 /home/nikos
 >
 > root@nikos [~]# chmod 755 /home/nikos/public_html/
 >
 > root@nikos [~]# chmod o+r /home/nikos/public_html/index.__html
 >
 > root@nikos [~]# chmod 711 /home/dauwin
 >
 > root@nikos [~]# chmod 755 /home/dauwin/public_html/
 >
 > root@nikos [~]# chmod o+r /home/dauwin/public_html/__index.html
 >
 > root@nikos [~]#
 >
 >
 >
 > setsebool -P httpd_enable_homedirs true
 >
 > chcon -R -t httpd_sys_content_t /home/testuser/public_html
 >
 > (the last one one failed though)
 >
 >
 >
 > the i restarted Apache but the problem is still there.
 >
 >
 >
 > ===
 >
 > ni...@superhost.gr  [~]# [Thu Jun 13
19:50:57 2013] [error] [client
 >
 > 79.103.41.173] Error in sys.excepthook:
 >
 > [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] ValueError:
 >
 > underlying buffer has been detached
 >
 > [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173]
 >
 > [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] Original
 >
 > exception was:
 >
 > [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173] Traceback
 >
 > (most recent call last):
 >
 > [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173]   File

 >
 > "/home/nikos/public_html/cgi-__bin/metrites.py", line 213, in

 >
 > [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173]
with open(

 >
 > '/home/nikos/public_html/' + page, encoding='utf-8' ) as f:
 >
 > [Thu Jun 13 19:50:57 2013] [error] [client 79.103.41.173]

 >
 > FileNotFoundError: [Errno 2] \\u0394\\u03b5\\u03bd
 >
 > \\u03c5\\u03c0\\u03ac\\u03c1\\__u03c7\\u03b5\\u03b9
 >
 > \\u03c4\\u03ad\\u03c4\\u03bf\\__u03b9\\u03bf
 >
 > \\u03b1\\u03c1\\u03c7\\u03b5\\__u03af\\u03bf \\u03ae
 >
 > \\u03ba\\u03b1\\u03c4\\u03ac\\__u03bb\\u03bf\\u03b3\\u03bf\\__u03c2:
 >
 > '/home/nikos/public_html//__home/dauwin/public_html/index.__html'


SECOND TIME:

I'm not an apache wizard, and I'm too self important to really look
through all of your code.  i don't getting germs.  But, once again:

your code is not finding a file named this:
  '/home/nikos/public_html//home/dauwin/public_html/index.html'

The first part of this file path is:'/home/nikos/public_html

After that are TWO forward slashes which remind me of http:// and
following that is the path you want.  so, you need to put new batteries
in your brain, look through your mess and figure out what creates the
wrong file name for you


Well, sin

Re: Wrong website loaded when other requested

2013-06-13 Thread Nick the Gr33k

On 13/6/2013 9:37 μμ, Andreas Perstinger wrote:

On 13.06.2013 20:10, Nick the Gr33k wrote:
[nothing new]

Could you please stop spamming the whole internet with your problems.
Not only that you've posted two similar offtopic messages within only 6
minutes to this list, you've also crossposted to alt.os.linux (where it
is offtopic too) and to the forum at devshed.com (at least you've found
the right subforum there).

Thank you very much!


Andrea i need to fix this my friend.
I canoot relax or get a good night sleep until this and the files.py 
issue have been fixed.



--
What is now proved was at first only imagined!
--
http://mail.python.org/mailman/listinfo/python-list


Re: My son wants me to teach him Python

2013-06-13 Thread russ . pobox
I couldn't read every post here so don't know if this has been suggested, or if 
there is perhaps a better suggestion which I haven't read in this thread, but 
in as far as I've read I feel the need to recommend:
learnpythonthehardway.org

Knowing a little JavaScript and even allot of HTML doesn't take him out of the 
total noob category when it comes to programming (did someone say game 
programming? Hold your horses!). I took a visual basic course (which I dropped 
out of admittedly after 3 months) and still knew absolutely nothing, which 
isn't necessarily just because I'm dumb.

After eventually learning Python in incremental and sporadic episodes of free 
time, I did come across a few resources and by virtue of the frustration of 
having taken so long to learn to code in the easiest damn programming language 
to learn, I found myself scrutinizing allot of the tutorials I'd been passing 
by.

I noticed developers.google.com somewhere up there. That's just a no no. Sorry. 
Maybe some of the people here are more than "pretty smart" but there's a good 
chance it'll be over his head at first, and at first is a bad place to be in 
over your head when you're learning the fundamentals.

I also notice Invent with python. I personally would go for 2.x rather than 3 
but that aside, for reasons I'm too tired to word, I didn't find it a good fit 
for me. I takes a "dive right in" approach and well, I never did learn to swim.

Udacity was the third suggestion I noticed. This is also a no no. I completed 
the cs101 udacity course which I'm sure is the course in question here, and I 
loved it! Really I learn crap load from it, but at every step I asked myself, 
would this had helped if it was the first place I went to to learn to code? No. 
There were allot of gaps I noticed when looking from a complete beginners 
perspective and even though the course claims to has no prerequisites, I would 
have hated if I started with that. However that was last year and I think it 
was only a few months old, so it may be allot different now, I haven't checked.

I read How to think like a computer scientist, A byte of python, and even the 
official docs. The only one I came across that made me say "&*#! why didn't I 
google that?" was learnpythonthehardway.

I do think it depends a great deal on the individual, and for me personally, 
that style of learning was just it. For one you learn from the bottom up. It's 
a compulsion for some to know that that know a thing before they're brave 
enough to move forward. In cases where a "leap" is the only way forward, the 
tutor pulls you across that divide by your ankles. You feel a sense of 
obligation to take to his instruction. And above all, it greatly emphasizes the 
"learn by doing" approach, in small steps, not big projects that you end up 
completing just to get through it but don't learn much from.

So that's my recommendation. But all that aside, my biggest point would be, 
just pick one do it. As you can see if you read that, my biggest flaw was 
simply the lack of devotion to one path.

Game programming if he still wants to do that is another question entirely I 
feel. Fundamentals are fundamentals. The only variable is how long it might 
take him to get passed it. Even with Python, some people just never get it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program

2013-06-13 Thread buford . lumbar
Hi, I'm new to Python. Would someone be able to write me and/or to show me how 
to write a simple program that:

1-follows a hyperlink from MS Excel to the internet (one of many links like 
this, http://www.zipdatamaps.com/76180, for e.g.) and then,

2-copies some data (a population number, e.g. 54195) and then,

3-pastes that data back into the same MS Excel spreadsheet, into the adjacent 
cell.

... and that’s it... row after row of hyperlinks all in one column...

Please, please help me my wrist is starting to hurt a lot. You would have my 
greatest appreciation for your help!

thank you, Buford
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >