Open Question - I'm a complete novice in programming so please bear with me...Is python equivalent to C, C++ and java combined?

2014-01-11 Thread pintreo mardi
Hi, I've just begun to learn programming, I have an open question for the group:
Is the Python language an all in one computer language which could replace C, 
C++, Java etc.. I only ask becuase I am starting off with python and I want to 
learn everything in basic and advanced programming with python itself...So any 
advice and suggestions would be more than welcome.
Thanks!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Open Question - I'm a complete novice in programming so please bear with me...Is python equivalent to C, C++ and java combined?

2014-01-11 Thread Chris Angelico
On Sat, Jan 11, 2014 at 7:07 PM, pintreo mardi  wrote:
> Hi, I've just begun to learn programming, I have an open question for the 
> group:
> Is the Python language an all in one computer language which could replace C, 
> C++, Java etc.. I only ask becuase I am starting off with python and I want 
> to learn everything in basic and advanced programming with python itself...So 
> any advice and suggestions would be more than welcome.
> Thanks!!

Python is a viable applications language, yes. There's nothing you
can't write in Python that you can write in (say) Java - both
languages are what's called "Turing complete". Every language has its
special focus, though, so there'll be some things that are far easier
in one language than another. In general, Python is a fine language
for simple tasks like printing "Hello, world", for scripting, for
writing GUI programs, and for building web applications. It's not
restricted to tiny projects or to huge ones. There's no critical limit
on the amount of "stuff" you can do before the code gets unwieldy, for
instance, nor is there a level below which it's just too much hassle
to put together a program.

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


Porting c extension - PyBuffer_New() deprecated in python3. What's the replacement?

2014-01-11 Thread Mark Heieis

Hi

I need to convert the following existing c extension code to support 
Python 3.


// --- existing code --

// PyBuffer_New() deprecated in python3
if (!(pyBuf = PyBuffer_New(len)))
{
return NULL;
}

// should use memoryview object in python3
if (PyObject_AsWriteBuffer(pyBuf, &cbuf, &len))
{
Py_DECREF(pyBuf);
return NULL ;
}

// fill in cbuf
...

return pyBuf ;

//---

I'm somewhat confounded in finding an equivalent (PyBuffer_New()) for 
creating a buffer of size len that has continuous memory in the c 
extension function for python3. cbuf is manipulated/filled in using c, 
after which the created pyBuf is then returned. So far, I haven't found 
much in the way of examples/doc for porting the deprecated 
Python-/C-level buffer API calls to the new C-level buffer 
API/memoryview object model.


Any guidance or direction to existing doc/example is much appreciated.

TIA.




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


Re: Time zones and why they change so damned often

2014-01-11 Thread Gene Heskett
On Friday 10 January 2014 21:52:49 Dennis Lee Bieber did opine:

> On Fri, 10 Jan 2014 19:55:37 + (UTC), Grant Edwards
> 
>  declaimed the following:
> >It got darned cold here in Minnesota on Monday (-23F in Minneapolis,
> >-35F in Embarass), but Hell is in Michigan -- where it only got down
> >to -15F.
> 
>   Does that mean that Hell should be Embarassed?

Nah, they are used to it by now.

Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 

May cause drowsiness.
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
 law-abiding citizens.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Porting c extension - PyBuffer_New() deprecated in python3. What's the replacement?

2014-01-11 Thread Stefan Behnel
Mark Heieis, 11.01.2014 06:47:
> I need to convert the following existing c extension code to support Python 3.
> 
> // --- existing code --
> 
> // PyBuffer_New() deprecated in python3
> if (!(pyBuf = PyBuffer_New(len)))
> {
> return NULL;
> }
> 
> // should use memoryview object in python3
> if (PyObject_AsWriteBuffer(pyBuf, &cbuf, &len))
> {
> Py_DECREF(pyBuf);
> return NULL ;
> }
> 
> // fill in cbuf
> ...
> 
> return pyBuf ;
> 
> //---
> 
> I'm somewhat confounded in finding an equivalent (PyBuffer_New()) for
> creating a buffer of size len that has continuous memory in the c extension
> function for python3. cbuf is manipulated/filled in using c, after which
> the created pyBuf is then returned. So far, I haven't found much in the way
> of examples/doc for porting the deprecated Python-/C-level buffer API calls
> to the new C-level buffer API/memoryview object model.
> 
> Any guidance or direction to existing doc/example is much appreciated.

If the extension isn't huge, you should consider rewriting it in Cython.
That can usually be done quite quickly - the main thing is to figure out
what the verbose C code actually does and write it down in much simpler
Python code. And it will make it easy to make the code portable and fast.
Also likely safer and more generic and versatile, because Cython covers
away a lot of the annoying boilerplate, ref-counting issues, type
conversions, etc.

For your specific problem at hand, you could use Cython's memory views:

http://docs.cython.org/src/userguide/memoryviews.html

They allow you to convert the input value to a 1-dim char buffer (or
whatever you need, but you mentioned the old Py2 buffer interface, which
can't do much more) by saying

cdef char[:] my_memview = some_python_object

If you need to pass the unpacked buffer into C code, you can get the
address as "&my_memview[0]" (i.e. the address of the first item in the
buffer). Memory views themselves support fast slicing and indexing, so you
can efficiently work with them using the normal Python slicing/indexing syntax.

In case what you actually receive are not arbitrary buffers but simple byte
strings or bytearray instances, you can even use the normal byte string
coercion in Cython and simply say

cdef char* c_string = some_python_byte_string_object

and then use that pointer to pass it on into C.

I've written a string processing tutorial for Cython here:

http://docs.cython.org/src/tutorial/strings.html

These things may take a moment to learn, especially if you are used to
doing everything in excessive manual detail in C code, but once you are
through that, you should get things done much more quickly than when trying
to do them by hand.

Stefan


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


Re: With this artifact, everyone can easily invent new languages

2014-01-11 Thread Simeon Chaos
Thank you, James. I didn't know this group before. I'll post this message there.

在 2014年1月11日星期六UTC+8下午3时47分33秒,James Harris写道:
> "Simeon Chaos"  wrote in message 
> 
> news:bb7d8d30-845a-4a3d-9b03-dee71ef42986 @googlegroups.com...
> 
> > ? 2014?1?11UTC+8??10?17?33?,Chris Angelico??:
> 
> > > On Sat, Jan 11, 2014 at 11:59 AM, Simeon Chaos wrote:
> 
> > >
> 
> > > > All along, the design of programming languages is a complex task. 
> 
> > > > Because we need to understand the esoteric compiler theory and 
> 
> > > > technology, and one of the most critical and very difficult part is to 
> 
> > > > define the rules of the new language and to parse with them.To solve 
> 
> > > > this problem, there have been many theories , techniques and tools . 
> 
> > > > These tools can be roughly divided into two categories: one is parser 
> 
> > > > generator, another is to write the parser by hand with or without a 
> 
> > > > parser library.
> 
> 
> 
> > Yes, it's complex to design a new language. So don't let the tool stand in 
> 
> > the way. There is a saying: Grinding a chopper will not hold up the work 
> 
> > of cutting firewood.
> 
> 
> 
> To the OP: this is a suitable topic for comp.lang.misc which is used for 
> 
> discussions about programming language design and implementation such as 
> 
> parse mechanisms.
> 
> 
> 
> James

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


Re: Send array back in result from urllib2.urlopen(request, postData)

2014-01-11 Thread vanommen . robert

I understand the problem now. the echo is a string, wich can contain text but 
no array.

I've changed the PHP script so I get only text separated with comma's and in 
python I separate the textfields and declare them in the array. With the split 
methode I saw in the answer of J. Gordon. Thank you for that.

@MRAB
When I encode the data in PHP and send it to Python, the results where the same.

Thanks everyone for the answers!

Greetings Robert.

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


Re: Open Question - I'm a complete novice in programming so please bear with me...Is python equivalent to C, C++ and java combined?

2014-01-11 Thread pintreo mardi
On Saturday, January 11, 2014 1:51:53 PM UTC+5:30, Chris Angelico wrote:
> On Sat, Jan 11, 2014 at 7:07 PM, pintreo mardi  wrote:
> 
> > Hi, I've just begun to learn programming, I have an open question for the 
> > group:
> 
> > Is the Python language an all in one computer language which could replace 
> > C, C++, Java etc.. I only ask becuase I am starting off with python and I 
> > want to learn everything in basic and advanced programming with python 
> > itself...So any advice and suggestions would be more than welcome.
> 
> > Thanks!!
> 
> 
> 
> Python is a viable applications language, yes. There's nothing you
> 
> can't write in Python that you can write in (say) Java - both
> 
> languages are what's called "Turing complete". Every language has its
> 
> special focus, though, so there'll be some things that are far easier
> 
> in one language than another. In general, Python is a fine language
> 
> for simple tasks like printing "Hello, world", for scripting, for
> 
> writing GUI programs, and for building web applications. It's not
> 
> restricted to tiny projects or to huge ones. There's no critical limit
> 
> on the amount of "stuff" you can do before the code gets unwieldy, for
> 
> instance, nor is there a level below which it's just too much hassle
> 
> to put together a program.
> 
> 
> 
> ChrisA

Thanks mate!! I'm a bit relieved. If I could get some really good books on 
programming with python, those for the beginners would be very helpful.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Open Question - I'm a complete novice in programming so please bear with me...Is python equivalent to C, C++ and java combined?

2014-01-11 Thread Mark Lawrence

On 11/01/2014 08:07, pintreo mardi wrote:

Hi, I've just begun to learn programming, I have an open question for the group:
Is the Python language an all in one computer language which could replace C, 
C++, Java etc.. I only ask becuase I am starting off with python and I want to 
learn everything in basic and advanced programming with python itself...So any 
advice and suggestions would be more than welcome.
Thanks!!



https://mail.python.org/pipermail/python-list/2002-November/141486.html

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


Mark Lawrence

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


Re: Open Question - I'm a complete novice in programming so please bear with me...Is python equivalent to C, C++ and java combined?

2014-01-11 Thread Mark Lawrence

On 11/01/2014 10:10, pintreo mardi wrote:

On Saturday, January 11, 2014 1:51:53 PM UTC+5:30, Chris Angelico wrote:

On Sat, Jan 11, 2014 at 7:07 PM, pintreo mardi  wrote:


Hi, I've just begun to learn programming, I have an open question for the group:



Is the Python language an all in one computer language which could replace C, 
C++, Java etc.. I only ask becuase I am starting off with python and I want to 
learn everything in basic and advanced programming with python itself...So any 
advice and suggestions would be more than welcome.



Thanks!!




Python is a viable applications language, yes. There's nothing you

can't write in Python that you can write in (say) Java - both

languages are what's called "Turing complete". Every language has its

special focus, though, so there'll be some things that are far easier

in one language than another. In general, Python is a fine language

for simple tasks like printing "Hello, world", for scripting, for

writing GUI programs, and for building web applications. It's not

restricted to tiny projects or to huge ones. There's no critical limit

on the amount of "stuff" you can do before the code gets unwieldy, for

instance, nor is there a level below which it's just too much hassle

to put together a program.



ChrisA


Thanks mate!! I'm a bit relieved. If I could get some really good books on 
programming with python, those for the beginners would be very helpful.



No, no, no, this can't be happening!!!  Surely outlook can't have caught 
double spaced google disease, please see 
https://wiki.python.org/moin/GoogleGroupsPython for a description of the 
original problem and compare it to what's shown above.


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


Mark Lawrence

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


INTRODUCING ISLAM

2014-01-11 Thread bv4bv4bv4
INTRODUCING ISLAM
 
I. ISLAM AND MUSLIMS
The name of this religion is Islam, the root of which is Silm and Salam which 
means peace. Salam may also mean greeting one another with peace. One of the 
beautiful names of God is that He is the Peace. It means more than that: 
submission to the One God, and to live in peace with the Creator, within one's 
self, with other people and with the environment. Thus, Islam is a total system 
of living. A Muslim is supposed to live in peace and harmony with all these 
segments; hence, a Muslim is any person anywhere in the world whose obedience, 
allegiance, and loyalty are to God, the Lord of the Universe.
II. MUSLIMS AND ARABS
The followers of Islam are called Muslims. Muslims are not to be confused with 
Arabs. Muslims may be Arabs, Turks, Persians, Indians, Pakistanis, Malaysians, 
Indonesians, Europeans, Africans, Americans, Chinese, or other nationalities.
An Arab could be a Muslim, a Christian, a Jew or an atheist. Any person who 
adopts the Arabic language is called an Arab. However, the language of the 
Qur'an (the Holy Book of Islam) is Arabic. Muslims all over the world try to 
learn Arabic so that they may be able to read the Qur'an and understand its 
meaning. They pray in the language of the Qur'an, namely Arabic. Supplications 
to God could be in any language.
While there are one billion Muslims in the world there are about 200 million 
Arabs. Among them, approximately ten percent are not Muslims. Thus Arab Muslims 
constitute only about twenty percent of the Muslim population of the world.
III. ALLAH THE ONE AND THE ONLY GOD
Allah is the name of the One and Only God. Allah has ninety-nine beautiful 
names, such as: The Gracious, The Merciful, The Beneficent, The Creator, The 
All-Knowing, The All-Wise, The Lord of the Universe, The First, The Last, and 
others.
He is the Creator of all human beings. He is the God for the Christians, the 
Jews, the Muslims, the Buddhists, the Hindus, the atheists, and others. Muslims 
worship God whose name is Allah. They put their trust in Him and they seek His 
help and His guidance.
IV. MUHAMMAD
Muhammad was chosen by God to deliver His Message of Peace, namely Islam. He 
was born in 570 C.E. (Common Era) in Makkah, Arabia. He was entrusted with the 
Message of Islam when he was at the age of forty years. The revelation that he 
received is called the Qur'an, while the message is called Islam.
Muhammad is the very last Prophet of God to mankind. He is the final Messenger 
of God. His message was and is still to the Christians, the Jews and the rest 
of mankind. He was sent to those religious people to inform them about the true 
mission of Jesus, Moses, Jacob, Isaac, and Abraham.
Muhammad is considered to be the summation and the culmination of all the 
prophets and messengers that came before him. He purified the previous messages 
from adulteration and completed the Message of God for all humanity. He was 
entrusted with the power of explaining, interpreting and living the teaching of 
the Qur'an.
V. SOURCE OF ISLAM
The legal sources of Islam are the Qur'an and the Hadith. The Qur'an is the 
exact word of God; its authenticity, originality and totality are intact. The 
Hadith is the report of the sayings, deeds and approvals of the Prophet 
Muhammad. The Prophet's sayings and deeds are called Sunnah. The Seerah is the 
writings of followers of Muhammad about the life of the Prophet. Hence, it is 
the life history of the Prophet Muhammad which provides examples of daily 
living for Muslims.
VI. SOME ISLAMIC PRINCIPLES
A. Oneness of God:
He is One and the Only One. He is not two in one or three in one. This means 
that Islam rejects the idea of trinity or such a unity of God which implies 
more than one God in one. 
B. Oneness of mankind:
People are created equal in front of the Law of God. There is no superiority 
for one race over another. God made us of different colors, nationalities, 
languages and beliefs so as to test who is going to be better than others. No 
one can claim that he is better than others. It is only God Who knows who is 
better. It depends on piety and righteousness.

C. Oneness of Messengers and the Message:
Muslims believe that God sent different messengers throughout the history of 
mankind. All came with the same message and the same teachings. It was the 
people who misunderstood and misinterpreted them.
Muslims believe in Noah, Abraham, Isaac, Ismail, Jacob, Moses, David, Jesus, 
and Muhammad. The Prophets of Christianity and Judaism are indeed the Prophets 
of Islam.

D. Angels and the Day of Judgment:
Muslims believe that there are unseen creatures such as angels created by God 
in the universe for special missions.
Muslims believe that there is a Day of Judgment when all people of the world 
throughout the history of mankind till the last day of life on earth, are to be 
brought for accounting, reward and punishment.

E. Innocence of Man at Birth:
Muslim believe that people are born free

Re: Time zones and why they change so damned often

2014-01-11 Thread Alister
On Sat, 11 Jan 2014 07:52:36 +, Bob Martin wrote:
we dont have "Daylight saving time" we switch between GMT (Greenwich
Mean Time) and BST (British Summer Time) at some point in the past we
have also used DST (Double Summer Time).
>>>
>>> British Summer Time *is* Daylight Saving Time.
>>
>>My point is in the UK we have never refered to it as Daylight saving
>>Time that is an Americanism :-)
> 
> Sorry, but you are wrong again!
> Just Google it.

Wikipedia

Daylight saving time (DST)—usually referred to as Summer Time in the 
United Kingdom

I had never heard the term daylight savings untill windows added it as a 
tick box.



-- 
And I alone am returned to wag the tail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Time zones and why they change so damned often

2014-01-11 Thread Alister
On Sat, 11 Jan 2014 11:10:41 +, Alister wrote:

> On Sat, 11 Jan 2014 07:52:36 +, Bob Martin wrote:
>we dont have "Daylight saving time" we switch between GMT (Greenwich
>Mean Time) and BST (British Summer Time) at some point in the past we
>have also used DST (Double Summer Time).

 British Summer Time *is* Daylight Saving Time.
>>>
>>>My point is in the UK we have never refered to it as Daylight saving
>>>Time that is an Americanism :-)
>> 
>> Sorry, but you are wrong again!
>> Just Google it.
> 
> Wikipedia
> 
> Daylight saving time (DST)—usually referred to as Summer Time in the
> United Kingdom
> 
> I had never heard the term daylight savings untill windows added it as a
> tick box.



or a more Authoritave souce https://www.gov.uk/when-do-the-clocks-change

The period when the clocks are 1 hour ahead is called British Summer Time 
(BST). 

-- 
The earth is like a tiny grain of sand, only much, much heavier.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Time zones and why they change so damned often

2014-01-11 Thread Alister
On Sat, 11 Jan 2014 11:10:41 +, Alister wrote:

> On Sat, 11 Jan 2014 07:52:36 +, Bob Martin wrote:
>we dont have "Daylight saving time" we switch between GMT (Greenwich
>Mean Time) and BST (British Summer Time) at some point in the past we
>have also used DST (Double Summer Time).

 British Summer Time *is* Daylight Saving Time.
>>>
>>>My point is in the UK we have never refered to it as Daylight saving
>>>Time that is an Americanism :-)
>> 
>> Sorry, but you are wrong again!
>> Just Google it.
> 
> Wikipedia
> 
> Daylight saving time (DST)—usually referred to as Summer Time in the
> United Kingdom
> 
> I had never heard the term daylight savings untill windows added it as a
> tick box.



or a more Authoritave souce https://www.gov.uk/when-do-the-clocks-change

The period when the clocks are 1 hour ahead is called British Summer Time 
(BST). 

-- 
The earth is like a tiny grain of sand, only much, much heavier.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re:python first project

2014-01-11 Thread Dave Angel
 ngangsia akumbo  Wrote in message:
> Hi everyone, 
> 
> I have been around this group for some time and i saw that we have very 
> helpful people here.
> 
Welcome to the group,  and to Python. 

> i have been learning python just for about 5 months now and i have been given 
> a task to do. This will be a leap into the programming industry for me.
> 
Is this a class assignment,  a book assignment, a self assignment,
  or is it to be used by a real business,  perhaps to replace
 manual methods? 

> 
> i am programming a system that will be giving details about finance, 
> purchase(bills pending bills and paid bill), employees record and salary 
> details, warehouse records.
> 
> That is just all i intend to do this all on one GUI application window 

But your code so far is all for a terminal window.  Nothing wrong
 with that, but if the professor is expecting GUI, that's
 different.  A GUI might be tkinter or qt or Wxpython or
 ...

> and to make it to be able to keep records for all the transaction which has 
> been done inputted.  

A key point.  So you need persistence.  You're going to need to
 write data to a file,  and reread it next time the program is
 run. The file might be a bunch of text lines, or it might be a
 database.  And it might belong to this program or be shared, even
 across multiple machines. 

> 
> I have started programming it , but i still feel there are a lot of things i 
> miss out.

I second the recommendation for version 3. And I suggest that if
 this is a business assignment, it's a lot harder than you think. 
 For example,  handling dollars and cents with floats is usually a
 mistake. 
> 
> Please i need some support from any honest person, please and also how to 
> guide me complete this.
> 

> 
> 
> 


-- 
DaveA nr



Android NewsGroup Reader
http://www.piaohong.tk/newsgroup

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


How to get Mac address of ethernet port?

2014-01-11 Thread Sam
I would like to use python to retrieve the mac address of the ethernet port. 
Can this be done? Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to get Mac address of ethernet port?

2014-01-11 Thread Andriy Kornatskyy
Sam,

How about this?

from uuid import getnode as get_mac
'%012x' % get_mac()

Thanks.

Andriy Kornatskyy

On Jan 11, 2014, at 4:26 PM, Sam  wrote:

> I would like to use python to retrieve the mac address of the ethernet port. 
> Can this be done? Thank you.
> -- 
> https://mail.python.org/mailman/listinfo/python-list

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


Re: How to get Mac address of ethernet port?

2014-01-11 Thread Chris Angelico
On Sun, Jan 12, 2014 at 1:26 AM, Sam  wrote:
> I would like to use python to retrieve the mac address of the ethernet port. 
> Can this be done? Thank you.
>

Did you try searching the web for 'python retrieve mac address' or similar?

There are several options offered.

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


Re: How to get Mac address of ethernet port?

2014-01-11 Thread Chris Angelico
On Sun, Jan 12, 2014 at 1:35 AM, Andriy Kornatskyy
 wrote:
> from uuid import getnode as get_mac
> '%012x' % get_mac()
>

Code golf! Put colons in that, with as little code as possible.

# Way too verbose.
import uuid
l=list("%012x"%uuid.getnode())
l[10:10]=l[8:8]=l[6:6]=l[4:4]=l[2:2]=':'
mac = ''.join(l)

# Shorter but not short enough
import uuid
s="%012x"%uuid.getnode()
mac = ':'.join(s[i*2:i*2+2] for i in range(6))

:)

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


Re: How to get Mac address of ethernet port?

2014-01-11 Thread Skip Montanaro
This is slightly longer than ChrisA's second solution:

>>> import uuid
>>> s = "%12x" % uuid.getnode()
>>> ":".join(x+y for x, y in zip(s[::2], s[1::2]))
'18:03:73:cb:2a:ee'

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


Re: With this artifact, everyone can easily invent new languages

2014-01-11 Thread James Harris
"Simeon Chaos"  wrote in message 
news:[email protected]...
> Thank you, James. I didn't know this group before. I'll post this message 
> there.

You're welcome. It can be hard to find apt groups on Usenet because there 
are so many. I don't think there was ever a group for programming language 
design (or invention) so that one which was about miscellaneous languages 
picked up the topic.

By the way, you could use comp.lang.misc simply for an announcement such as 
you posted here. If you want to start a discussion about an aspect of your 
design, however, the best option is to post a specific topic.

James


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


Re: Open Question - I'm a complete novice in programming so please bear with me...Is python equivalent to C, C++ and java combined?

2014-01-11 Thread Roy Smith
In article <[email protected]>,
 pintreo mardi  wrote:

> Hi, I've just begun to learn programming, I have an open question for the 
> group:
> Is the Python language an all in one computer language which could replace C, 
> C++, Java etc.. I only ask becuase I am starting off with python and I want 
> to learn everything in basic and advanced programming with python itself...So 
> any advice and suggestions would be more than welcome.
> Thanks!!

That's a really hard question to answer, or at least to answer well.

At a theoretical level, when you ask, "Is Python equivalent to C, C++ 
and Java", the answer is "yes".  In computer science, programming 
languages are classified by whether they are "Turing Complete" or not 
(google that for more info).  In theory, any Turing Complete language is 
capable of writing all programs which can be written in any other Turing 
Complete language.  All of the languages you mention are Turing 
Complete, so, theoretically, they are all equivalent.

But, at a more practical level, some languages are easier to learn, some 
run faster, some are more portable, some are more convenient to use, 
etc.  If I had to rank the languages you mention by a few categories, 
I'd say something like:

Python: Easiest to learn (and use), slowest execution speed.

C: Pretty easy to learn, but difficult to write large projects in, 
fastest execution speed.

C++: Hardest to learn, hard to use, speed close to C.

Java: Somewhere in-between Python and C++ on all counts.

All of these are currently in widespread commercial use today, so you 
can't go too far wrong staring out with any of them.  The TIOBE people 
have been tracking programming language popularity for a long time 
(http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html), so 
that's a good place to get some vague idea of what's hot and what's not.

One thing to be aware of is that some programming domains require a 
specific language.  If you want to do iOS, you need Objective C.  For 
Android, Java.  Web front-end programming, Javascript.  No getting away 
from those.  In the server environment, it's a much more wide-open 
field.  People write web servers, for example, in Python, Ruby, Scala, 
Javascript, PHP, Java, and probably a host of other languages.

This has already turned into a longer essay than I intended, but there's 
just one thing I wanted to add.  Whatever you pick to learn first, 
realize that if you embark on a life-long career in programming, it 
won't be your last.  Languages come and go.  I've done serious work in 
(in vaguely chronological order) Fortran, C, Python, Tcl, Perl, C++, and 
PHP.

So, pick one, spend a year getting really good at it, then pick another 
language, preferably one that's very different, and learn that too.  
Repeat every so often :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to get Mac address of ethernet port?

2014-01-11 Thread James Harris
"Andriy Kornatskyy"  wrote in message 
news:[email protected]...
> Sam,
>
> How about this?
>
> from uuid import getnode as get_mac
> '%012x' % get_mac()

AIUI that will return a mac address even if there isn't one. That may or may 
not suit the OP.

To the OP, depending on what you want to do remember that a machine can have 
more than one mac address and that a mac address can differ from the 
burned-in address (BIA) as some cards allow the effective mac address to be 
changed in software. So it's possible that two machines could show the same 
mac address.

James


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


Re: python first project

2014-01-11 Thread Denis McMahon
On Fri, 10 Jan 2014 20:18:32 -0800, ngangsia akumbo wrote:

> i have been learning python just for about 5 months now and i have been
> given a task to do. This will be a leap into the programming industry
> for me.
> 
> i am programming a system that will be giving details about finance,
> purchase(bills pending bills and paid bill), employees record and salary
> details, warehouse records.

It sounds as if your project has many aspects to it which may require you 
to understand and implement many different computing tasks.

For example:

You need to either analyse the data records that are required and produce 
a suitable database schema, or you need to work with an existing database 
schema. This may require some competence in developing database schemas, 
and will almost certainly require some sql knowledge in the chosen 
database (not all sqls are equal).

You also need to develop a user interface. First of all you ned to 
consider who will access the user interface, and how? Mobile devices, 
desktop computers, both? Do you want os specific (eg ios, android) apps 
for mobile devices, or will you run in a mobile browser window?

Will the application run on a web server, or locally on a single machine? 
Or will several gui clients connect to a single server host? In the 
latter case, you'll need to develop communication protocols (using a 
webapp removes some of this workload, but is a compromise that may 
require that you need other competences, possibly including but not 
limited to html, javascript and css).

The most important phase of any project is the requirements capture, for 
if you do not capture all the requirements of all the users, you will not 
deliver the project that they want. Users are not just the people who sit 
in front of the screens, they may also be people who will want 
statistical reports based on the database, but who never expect to 
actually touch a computer themselves - they have secretaries for that 
sort of thing. However, if your system can't produce the report that the 
CEO or CFO wants at the end of each month / quarter / year, then it will 
be labelled as crap, even if no-one told you as the system designer that 
this report was required!

So, first of all, you need to go and talk to everyone in the company that 
will use this system and obtain from them details of what they expect the 
system to do, what data they expect to input, and what data they expect 
to receive as outputs from it. Once you understand this, you may be in a 
position to start defining the database schema, and only then are you 
ready to think about the code that will put data into, and get it from, 
the database.

-- 
Denis McMahon, [email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python first project

2014-01-11 Thread ngangsia akumbo
On Saturday, January 11, 2014 2:06:41 PM UTC+1, Dave Angel wrote:
> ngangsia akumbo  Wrote in message:
> 
> > Hi everyone, 
> 
> > 
> 
> > I have been around this group for some time and i saw that we have very 
> > helpful people here.
> 
> > 
> 
> Welcome to the group,  and to Python. 
> 
> 
> 
> > i have been learning python just for about 5 months now and i have been 
> > given a task to do. This will be a leap into the programming industry for 
> > me.
> 
> > 
> 
> Is this a class assignment,  a book assignment,

 a self assignment,

This will be use for real business. The ceo in person is willing to cut the 
office task. I am from cameroon west africa.
> 
>   or is it to be used by a real business,  perhaps to replace
> 
>  manual methods? 
> 
> 
> 
> > 
> 
> > i am programming a system that will be giving details about finance, 
> > purchase(bills pending bills and paid bill), employees record and salary 
> > details, warehouse records.
> 
> > 
> 
> > That is just all i intend to do this all on one GUI application window 
> 
> 
> 
> But your code so far is all for a terminal window.  Nothing wrong
> 
>  with that, but if the professor is expecting GUI, that's
> 
>  different.  A GUI might be tkinter or qt or Wxpython or
> 
>  ...
> 
> 
> 
> > and to make it to be able to keep records for all the transaction which has 
> > been done inputted.  
> 
> 
> 
> A key point.  So you need persistence.  You're going to need to
> 
>  write data to a file,  and reread it next time the program is
> 
>  run. The file might be a bunch of text lines, or it might be a
> 
>  database.  And it might belong to this program or be shared, even
> 
>  across multiple machines. 

when i talk of record i mean details of all what will be inputed by the 
employees should be kept as a record.

> 
> 
> 
> > 
> 
> > I have started programming it , but i still feel there are a lot of things 
> > i miss out.
> 
> 
> 
> I second the recommendation for version 3. And I suggest that if
> 
>  this is a business assignment, it's a lot harder than you think. 
> 
>  For example,  handling dollars and cents with floats is usually a
> 
>  mistake. 
> 

How hard is it? Please i need your support
> > 
> 
> > Please i need some support from any honest person, please and also how to 
> > guide me complete this.
> 
> > 
> 
> 
> 
> > 
> 
> > 
> 
> > 
> 
> 
> 
> 
> 
> -- 
> 
> DaveA nr
> 
> 
> 
> 
> 
> 
> 
> Android NewsGroup Reader
> 
> http://www.piaohong.tk/newsgroup

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


Re: How to get Mac address of ethernet port?

2014-01-11 Thread Roy Smith
In article ,
 "James Harris"  wrote:

> "Andriy Kornatskyy"  wrote in message 
> news:[email protected]...
> > Sam,
> >
> > How about this?
> >
> > from uuid import getnode as get_mac
> > '%012x' % get_mac()
> 
> AIUI that will return a mac address even if there isn't one. That may or may 
> not suit the OP.

Specifically, it says, "If all attempts to obtain the hardware address 
fail, we choose a random 48-bit number with its eighth bit set to 1 as 
recommended in RFC 4122".  Keep in mind that 4122 is all about 
generating globally unique strings.  The only reason it even talks about 
MAC addresses is in the context of one possible way to generate uuids.

If your goal is to get the MAC address for some sort of networking 
reason, you need to bear in mind what James says below:

> To the OP, depending on what you want to do remember that a machine can have 
> more than one mac address and that a mac address can differ from the 
> burned-in address (BIA) as some cards allow the effective mac address to be 
> changed in software. So it's possible that two machines could show the same 
> mac address.

If you don't believe that two machines can have the same MAC address, 
look up Hot Standby Router Protocol.  And if you don't believe a machine 
can ignore the BIA and assign a new MAC address in software, look up 
Decnet .
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python first project

2014-01-11 Thread ngangsia akumbo
On Saturday, January 11, 2014 5:29:39 AM UTC+1, Chris Angelico wrote:
> On Sat, Jan 11, 2014 at 3:18 PM, ngangsia akumbo  wrote:
> 
> > purch_price = input("Please enter the price for purchase made: ")
> 
> > purch_p = raw_input("Please enter the reason of this purchase made: ")
> 
> 
> 
> Never use input() in a Python 2 program... always use raw_input()
> 
> instead. You're mostly right, but you have a few cases where you're
> 
> using input(). Probably what you want is int(input()) or
> 
> float(input()).
> 
> 
> 
> Incidentally, is there a strong reason for using Python 2 for this? If
> 
> not, I'd recommend moving immediately to Python 3, as there are an
> 
> increasing number of advantages. Unless something actually binds you
> 
> to Py2, save yourself the trouble of shifting in a few years' time and
> 
> just use Py3 now.
> 
> 
> 
> ChrisA

Thanks for the reply
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: L[:]

2014-01-11 Thread Grant Edwards
On 2014-01-10, Terry Reedy  wrote:
> On 1/10/2014 12:38 PM, Albert-Jan Roskam wrote:
>> In Python Cookbook, one of the authors (I forgot who) consistently used the 
>> "L[:]" idiom like below. If the second line simply starts with "L =" (so no 
>> "[:]") only the name "L" would be rebound, not the underlying object. That 
>> was the author?? explanation as far as I can remember. I do not get that. 
>> Why is the "L[:]" idiom more memory-efficient here? How could the increased 
>> efficiency be demonstrated?
>>
>> #Python 2.7.3 (default, Sep 26 2013, 16:38:10) [GCC 4.7.2] on linux2
> L = [x ** 2 for x in range(10)]
> L[:] = ["foo_" + str(x) for x in L]
>
> Unless L is aliased, this is silly code.

And if L _is_ aliaised, it's probably trying to be too clever and
needs to be fixed.

-- 
Grant



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


Re: How to get Mac address of ethernet port?

2014-01-11 Thread Michael Torrie
On 01/11/2014 07:35 AM, Andriy Kornatskyy wrote:
> Sam,
> 
> How about this?
> 
> from uuid import getnode as get_mac
> '%012x' % get_mac()

This seems to work if you have only one ethernet adapter.  Most
computers have two (wired and wireless) adapters.

Getting a mac address is platform-specific, and the OP has not specified
what OS he is using.

On Windows I imagine you'd have to access the WMI subsystem in Windows.

On Linux you could access the /sys/devices/virtual/net/
file in the sysfs filesystem.  I'm sure there are other ways.

No idea on OS X.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python first project

2014-01-11 Thread Mark Lawrence

On 11/01/2014 16:31, ngangsia akumbo wrote:

On Saturday, January 11, 2014 5:29:39 AM UTC+1, Chris Angelico wrote:


Incidentally, is there a strong reason for using Python 2 for this? If

not, I'd recommend moving immediately to Python 3, as there are an

increasing number of advantages. Unless something actually binds you

to Py2, save yourself the trouble of shifting in a few years' time and

just use Py3 now.



ChrisA


Thanks for the reply



I'd like to wish you the best of luck with your project as you've chosen 
the second best programming language in the world :)


However if you wish to ask more questions would you please read and 
action this https://wiki.python.org/moin/GoogleGroupsPython to prevent 
us seeing the double line spacing above, thanks.


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


Mark Lawrence

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


Re: python first project

2014-01-11 Thread ngangsia akumbo
On Saturday, January 11, 2014 6:17:13 PM UTC+1, Dennis Lee Bieber wrote:
 On Fri, 10 Jan 2014 20:18:32 -0800 (PST), ngangsia akumbo



 
>   Do you have a requirements or use-case documentation, or even a manual
 
 paper system which you would be "duplicating" on the computer? This
 
 document should provide the information what/how the system should operate
 
 (use-cases will be narratives showing how a user would interact with the
 
 system, with a use-case for each potential operation [add new client, add
 
 billing, correct errors, produce reports]).
 
I have a paper with the instructions that was given to me, these guys just want 
something very simple. The CEO in concern want that every day he get in to the 
office , it does not matter the time. He should be able to see a record of all 
the transaction for that day from his desktop 
 
>   How familiar are you with double-entry bookkeeping (accounts
 
 receivable, etc.

i am not very familiar with that

 > or is this just client billing application which may or
 
 may not feed into the main company accounting system)? Tax laws? 

yeah just a client billing app

>(Or is
 
 "salary details" really just the human resources record of promotions/pay
 
 raises, and NOT actual payroll production).

Just salary, employee record, etc
 


>   Are you familiar with relational database design and normalization?

Not very familiar with that, but if i have the right info i can normalize in it
 
> While an object-relational mapper [ORM] may take out the need to know SQL,

Yes i have some knowledge of sql

> they don't help you design efficient/usable databases. Or is their an
 
 existing system/database you have to interface with.

What i need to do is simple, design an app for employees, finance sector, 
purchase, billing, bookkeeping etc. Ok there is not IT infrastructure in this 
firm, they have a group of workers just doing the manual input of data. so the 
ceo wants this data to interact with a program that can keep track of what is 
going in the company.


 
 
  
 
 
 >  You have three separate applications defined: stock/warehouse, human
 
 resource/payroll, and billing/accounting. You probably do not want a single
 
 GUI application for this (the people updating warehouse records should have
 
 no access to employee/salary/payroll, nor to the billing system).
 


Thanks very much for this brilliant idea 
 
> >I am also looking for guides and sources which can help me complete it.
>

 
 
>   Text books on accounting principles, relational database design
 
 concepts, system analysis (if there are no requirements/use-cases) which
 
 may cross over with Object-Oriented Analysis (Object-Oriented Design would
 
 come in AFTER the system has been analyzed; it is a bit closer to the
 
 programming level than requirements).
 
I did not fully understand this paragraph please 



 
 

 
 
 
>   There is no persistence between runs (that is, no tracking of
 
 information from one run to another). Your "financial sector" basically
 
 requires the user to already know what their balance is and is just telling
 
 them if it is positive or negative. No ability to save a balance and later
 
 have them add or subtract an amount from it.

Thanks for this point 

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


python querry on firebug extention

2014-01-11 Thread Jai
hello

   i am working on selenium module of python, i know how to make extension  
of firebug with selenium, but i  want to know how to use firebug  extension 
with request module / mechanize . i search a lot but unable to find it , please 
help .

technique similar like :-

from selenium import webdriver

fp = webdriver.FirefoxProfile()

fp.add_extension(extension='firebug-1.8.4.xpi')
fp.set_preference("extensions.firebug.currentVersion", "1.8.4") #Avoid startup 
screen
browser = webdriver.Firefox(firefox_profile=fp)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python first project

2014-01-11 Thread Wolfgang Keller
> i am programming a system that will be giving details about finance,
> purchase(bills pending bills and paid bill), employees record and
> salary details, warehouse records.
> 
> That is just all i intend to do this all on one GUI application
> window and to make it to be able to keep records for all the
> transaction which has been done inputted.  

If "keeping records" implies significant amounts of data, then this is
a typical case of a database application.

There are a couple of Python frameworks for this kind of application:

using wxPython:
Dabo  http://www.dabodev.com (already mentioned)
Defis http://sourceforge.net/projects/defis/ (Russian only)
GNUe  http://www.gnuenterprise.org/

using PyQt:
Pypapihttps://pypi.python.org/pypi/PyPaPi/0.8
Camelot   http://www.python-camelot.com/
Qtalchemy http://www.qtalchemy.org/
Thyme http://clocksoft.co.uk/downloads/
Kexi  http://www.kexi-project.org/

using PyGTK:
SQLkithttp://sqlkit.argolinux.org/
Kiwi  http://www.async.com.br/projects/kiwi/
Glom  http://www.glom.org

Sincerely,

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


Re: How to get Mac address of ethernet port?

2014-01-11 Thread Chris Angelico
On Sun, Jan 12, 2014 at 3:29 AM, Roy Smith  wrote:
> If you don't believe that two machines can have the same MAC address,
> look up Hot Standby Router Protocol.  And if you don't believe a machine
> can ignore the BIA and assign a new MAC address in software, look up
> Decnet .

Most people shouldn't have to worry about MAC address
duplication/collision on the same subnet (I used MACs as a means of
guaranteeing uniqueness among a pool of application servers, for
instance), but MAC switching in software can occur in a typical home
internet connection scenario. We had a connection set up a few years
ago where the ISP tech recorded the source MAC into the far end, and
only that MAC would work - so when I stuck in a different router, I
needed to switch it to the old MAC before it could establish a
connection. Stupid? Yes. Unusual? I hope so, but still more likely
than coming across DECnet in a typical home!

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


Re: Porting mailing list underused?

2014-01-11 Thread Mark Lawrence

On 10/01/2014 21:31, Mark Lawrence wrote:

On 10/01/2014 20:38, Skip Montanaro wrote:

Anyone in the
know who can explain this phenomenon?


I don't think I can explain it authoritatively, but I can hazard a
guess. Skimming the archives sorted by author, it looks like most/all
the correspondents are Python core developers. That leads me to
believe this was a list created for the core Python developers to
discuss issues related to porting tools such as 2to3 or six. I doubt
it was intended for Python programmers to get help porting their own
code. From the Python core development perspective, I think automated
porting tools are likely pretty mature at this point and don't warrant
a lot of discussion.

Skip



If the dumbo OP had remembered to say that
https://mail.python.org/mailman/listinfo/python-porting states rather
vaguely "This list is to contain discussion of porting Python code
between versions, mainly from Python 2.x to 3.x." it might have helped
garner more answers.  Still, if we leave the list open for long enough
we'll all be able to discuss porting python 2.x to python 4.x :)



I've now found this 
https://mail.python.org/pipermail/python-dev/2008-December/083951.html


QUOTE
It is a public mailing list open to everyone.  We expect active 
participation of many people porting their libraries/programs, and hope 
that the list can be a help to all wanting to go this (not always smooth 
:-) way.

ENDQUOTE

Strikes me that if more people had participated, or maybe even known 
about it, we currently wouldn't be on the edge of WWIII regarding PEP 460.


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


Mark Lawrence

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


Re: Porting mailing list underused?

2014-01-11 Thread Ethan Furman

On 01/11/2014 01:51 PM, Mark Lawrence wrote:


I've now found this 
https://mail.python.org/pipermail/python-dev/2008-December/083951.html

QUOTE
It is a public mailing list open to everyone.  We expect active participation 
of many people porting their
libraries/programs, and hope that the list can be a help to all wanting to go 
this (not always smooth :-) way.
ENDQUOTE


Thanks for finding this mailing list.  I have subscribed to it.  :)

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


Re: How to get Mac address of ethernet port?

2014-01-11 Thread Roy Smith
In article ,
 Chris Angelico  wrote:

> We had a connection set up a few years
> ago where the ISP tech recorded the source MAC into the far end, and
> only that MAC would work - so when I stuck in a different router, I
> needed to switch it to the old MAC before it could establish a
> connection. Stupid? Yes. Unusual? I hope so

Actually, I think it's pretty common.

I had exactly the same problem a few years ago.  My DSL router fried 
itself.  I got a new one and it was easier to make it fake out the old 
router's MAC than to get my carrier to update their head end 
configuration[1].

[1] Roy's law of dealing with service providers.  Anything you can do 
yourself is easier than interfacing with tech support.
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2014-01-11 Thread Dan Stromberg
Hi folks.

I have a setup.py problem that's driving me nuts.

I have a treap.py file that tries to "import * from pyx_treap.so", and
failing that, it'll "import * from py_treap.py" (sans extensions of
course).  Naturally, all 3 of these should be included - although in
the case of pyx_treap.so, it probably should be a .c that's included.

It is also intended to include nest.py, which has a simple form.

Well, treap.py, nest.py and pyx_treap.c are included fine, but I can't
seem to get py_treap.py to be included for some reason.

I get no errors during "python setup.py sdist upload", but upon
"python $(which pip) install treap", I get:
$ sudo /usr/bin/python $(which pip) install treap
Downloading/unpacking treap
  Running setup.py egg_info for package treap

file py_treap.py (for module py_treap) not found
Installing collected packages: treap
  Running setup.py install for treap
file py_treap.py (for module py_treap) not found
file py_treap.py (for module py_treap) not found

file py_treap.py (for module py_treap) not found
file py_treap.py (for module py_treap) not found
Successfully installed treap
Cleaning up...

And it's not successfully installed - py_treap.py is missing.  The pyx
code does its job, so the problem is masked, other than the messages
above, and the absence of py_treap.py from
/usr/local/lib/python2.7/dist-packages

I can clearly see py_treap.py in ./dist/treap-1.35.tar.gz - it's at
least getting packaged up that much.  It's not listed in
/usr/local/lib/python2.7/dist-packages/treap-1.31.egg-info/SOURCES.txt
, but I can see it in
/usr/local/lib/python2.7/dist-packages/treap-1.31.egg-info/top_level.txt
.

My setup.py is at:
http://stromberg.dnsalias.org/svn/treap/trunk/setup.py

I've tried that setup.py and several variations on that theme, but
none seem to include py_treap.py .

Please make some suggestions?  How can I get py_treap.py included in
the pip install?

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


Re: python first project

2014-01-11 Thread Chris Angelico
On Sun, Jan 12, 2014 at 9:10 AM, Dennis Lee Bieber
 wrote:
> Producing fancy reports for the CEO may be the last thing you
> implement, as it relies upon having a stable database design, business
> logic, and data entry.

>From the sound of things, it might be the ONLY thing to implement,
though, if the answer to your previous question is "Yes" (that is, if
everything's already in a big fat database). Otherwise, the OP's going
to be replicating stuff that businesses pay good money for - a full-on
accounting and warehousing system.

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


record pixel value with Python script

2014-01-11 Thread DPod

A scripting newbie question...

I'd like to write a Python script for ArcGIS 10.x (ArcPy or Python 2.6.5) that 
would record the pixel value for all pixels in a raster. Furthermore, I'd like 
to only record a given value once in the results. For example, if there are 23 
values of 180 overall, only record one instance of that value.

The raster in question is 4-band (6017 x 7715 pixels) so the results would have 
to include values for all pixels in each band, recorded separately by band. 
Ideally I'd like to write to an Excel file or at least a .csv file.

Any help and examples would be greatly appreciated.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: record pixel value with Python script

2014-01-11 Thread maxerickson
On Saturday, January 11, 2014 5:53:00 PM UTC-5, DPod wrote:

> 
> I'd like to write a Python script for ArcGIS 10.x (ArcPy or Python 2.6.5) 
> >that would record the pixel value for all pixels in a raster. Furthermore, 
> I'd >like to only record a given value once in the results. For example, if 
> there >are 23 values of 180 overall, only record one instance of that value.
> 
> The raster in question is 4-band (6017 x 7715 pixels) so the results would 
> >have to include values for all pixels in each band, recorded separately by 
> >band. Ideally I'd like to write to an Excel file or at least a .csv file.
> 

Can you install libraries?

Fetching the pixel values of an individual band is straightforward in PIL (and 
the fork Pillow), something like this:

from PIL import Image
im=Image.open("blah.jpg")
red=im.getdata(0)

If you can't install things you would need to figure out if ArcGIS has an API 
for fetching a band.

The filtering step is easy, you just want the set of values:

set(red)


Max



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


Re: record pixel value with Python script

2014-01-11 Thread DPod
On Saturday, January 11, 2014 3:35:13 PM UTC-8, [email protected] wrote:
> On Saturday, January 11, 2014 5:53:00 PM UTC-5, DPod wrote:
> 
> 
> 
> > 
> 
> > I'd like to write a Python script for ArcGIS 10.x (ArcPy or Python 2.6.5) 
> > >that would record the pixel value for all pixels in a raster. Furthermore, 
> > I'd >like to only record a given value once in the results. For example, if 
> > there >are 23 values of 180 overall, only record one instance of that value.
> 
> > 
> 
> > The raster in question is 4-band (6017 x 7715 pixels) so the results would 
> > >have to include values for all pixels in each band, recorded separately by 
> > >band. Ideally I'd like to write to an Excel file or at least a .csv file.
> 
> > 
> 
> 
> 
> Can you install libraries?
> 
> 
> 
> Fetching the pixel values of an individual band is straightforward in PIL 
> (and the fork Pillow), something like this:
> 
> 
> 
> from PIL import Image
> 
> im=Image.open("blah.jpg")
> 
> red=im.getdata(0)
> 
> 
> 
> If you can't install things you would need to figure out if ArcGIS has an API 
> for fetching a band.
> 
> 
> 
> The filtering step is easy, you just want the set of values:
> 
> 
> 
> set(red)
> 
> 
> 
> 
> 
> Max

No, installing libraries doesn't seem to be an option
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python first project

2014-01-11 Thread Dave Angel
 ngangsia akumbo  Wrote in message:
> On Saturday, January 11, 2014 2:06:41 PM UTC+1, Dave Angel wrote:
 
>> 
>> I second the recommendation for version 3. And I suggest that if
>> 
>>  this is a business assignment, it's a lot harder than you think. 
>> 
>>  For example,  handling dollars and cents with floats is usually a
>> 
>>  mistake. 
>> 
> 
> How hard is it? Please i need your support
>> > 
>> 
Not sure what units of measurement you'd like.   How about ten
 thousand lines of code?


-- 
DaveA nr



Android NewsGroup Reader
http://www.piaohong.tk/newsgroup

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


Re:Open Question - I'm a complete novice in programming so please bear with me...Is python equivalent to C, C++ and java combined?

2014-01-11 Thread Dave Angel
 pintreo mardi  Wrote in message:
> Hi, I've just begun to learn programming, I have an open question for the 
> group:
> Is the Python language an all in one computer language which could replace C, 
> C++, Java etc.. I only ask becuase I am starting off with python and I want 
> to learn everything in basic and advanced programming with python itself...So 
> any advice and suggestions would be more than welcome.
> Thanks!!
> 

As others have said you can do nearly anything in any of those
 languages.  But you can expect to learn and use many over time.
 I've used about 35 professionally,  and a few more for fun. I've
 done substantial work in machine language and also in microcode. 
 Sometimes I had to write the assembler, simulator, and debugger
 while the actual machine was being designed.  Was python an
 appropriate language to write add and subtract in?  Nope.
 

-- 
DaveA nr



Android NewsGroup Reader
http://www.piaohong.tk/newsgroup

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


Python 3 __bytes__ method

2014-01-11 Thread Ethan Furman
Python 3 has a new method, __bytes__.  The docs say: Called by bytes() to compute a byte-string representation of an 
object. This should return a bytes object.


I must admit I'm not entirely clear how this should be used.  Is anyone using 
this now?  If so, how?

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


Re: Python 3 __bytes__ method

2014-01-11 Thread Ethan Furman

On 01/11/2014 04:53 PM, Daniel da Silva wrote:


Where did you read this? I can't find any documentation about __bytes__ on 
google.


http://docs.python.org/3.3/reference/datamodel.html?highlight=__bytes__#object.__bytes__

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


Re: How to get Mac address of ethernet port?

2014-01-11 Thread Chris Angelico
On Sun, Jan 12, 2014 at 8:55 AM, Roy Smith  wrote:
> In article ,
>  Chris Angelico  wrote:
>
>> We had a connection set up a few years
>> ago where the ISP tech recorded the source MAC into the far end, and
>> only that MAC would work - so when I stuck in a different router, I
>> needed to switch it to the old MAC before it could establish a
>> connection. Stupid? Yes. Unusual? I hope so
>
> Actually, I think it's pretty common.

Sad.

> I had exactly the same problem a few years ago.  My DSL router fried
> itself.  I got a new one and it was easier to make it fake out the old
> router's MAC than to get my carrier to update their head end
> configuration[1].
>
> [1] Roy's law of dealing with service providers.  Anything you can do
> yourself is easier than interfacing with tech support.

Unless you expect that doing it yourself will take upwards of an hour,
don't even bother talking to tech support, at least with the ISPs I
know. There's only *ONE* time when I got results quicker than that
(or, say, half an hour absolute minimum): with iiNet, I rang their
support and got dropped into a classic IVR system, and one of the
options was "Press whatever to get the basic setup information for
your connection". A couple more prompts and I was given a prerecorded
pile of numbers and settings, one of which was the exact one I was
having trouble with. With any other kind of business, this sort of
thing belongs on the web site, but for obvious reasons that's less
useful for an ISP :)

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


Re: Python 3 __bytes__ method

2014-01-11 Thread Daniel da Silva
Where did you read this? I can't find any documentation about __bytes__ on
google.

Regards,
Daniel


On Sat, Jan 11, 2014 at 7:24 PM, Ethan Furman  wrote:

> Python 3 has a new method, __bytes__.  The docs say: Called by bytes() to
> compute a byte-string representation of an object. This should return a
> bytes object.
>
> I must admit I'm not entirely clear how this should be used.  Is anyone
> using this now?  If so, how?
>
> --
> ~Ethan~
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to get Mac address of ethernet port?

2014-01-11 Thread Sam
On Sunday, January 12, 2014 12:34:35 AM UTC+8, Michael Torrie wrote:
> On 01/11/2014 07:35 AM, Andriy Kornatskyy wrote:
> 
> 
> On Linux you could access the /sys/devices/virtual/net/
> 
> file in the sysfs filesystem.  I'm sure there are other ways.
> 

Thank you to everyone for the helpful answers. I am using Linux in this case. I 
think this is the direction I am looking for. Thanks!
-- 
https://mail.python.org/mailman/listinfo/python-list


Is it better to import python modules inside function or at the top? What are the pros and cons?

2014-01-11 Thread Sam
I have python modules which are used only in specific functions and the 
functions are not called all the time. Is it better to import the function 
inside the function only or is it a better practice to always import all 
modules at the top of the script? If I import the module inside the function, 
will it cause a big performance hit because of the import module action that 
gets to be called every time the function is called?

What are the pros and cons of each approach?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Open Question - I'm a complete novice in programming so please bear with me...Is python equivalent to C, C++ and java combined?

2014-01-11 Thread Matěj Cepl
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2014-01-11, 08:07 GMT, you wrote:
> Hi, I've just begun to learn programming, I have an open question for the 
> group:
> Is the Python language an all in one computer language which could replace C, 
> C++, Java etc.. I only ask becuase I am starting off with python and I want 
> to learn everything in basic and advanced programming with python itself...So 
> any advice and suggestions would be more than welcome.

- From one side this answer is probably as meaningful as the one 
from the Alice in Wonderland 
(http://www.gutenberg.org/files/19033/19033-h/19033-h.htm, page 
35): “Why is a raven like a writing-desk?” These are just 
   different programming languages each designed for different 
   purpose. On the other hand what people said about Turing 
   complete langauges is true as well. So, yes it is true that 
   any Turing complete language you can write anything you wrote 
   in another Turing complete language. It doesn’t mean however 
   that it would be as easy or as efficient tool for doing so.  
   Some languages are specialized for high-power low-level 
   specialist programming of low-level stuff (e.g., almost all 
   serious operating systems are written in C), some are better 
   suited for writing enormous complicated projects consisting 
   of thousands of modules (Java, C++, Ada), some are designed 
   to be very easy to write (that doesn’t mean primitive) 
   although the speed and processing power of the result may 
   suffer a little bit (JavaScript, Python, Perl, Ruby).

If you ask for the language to start to learn programming as 
such, then Python was oriiginally intended exactly for that 
purpose (fortunately, it was written so well, it is now used en 
masse for “serious” large programming projects as well). FOr the 
list of resources take a look at 
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers .
Particularly, I’ve heard a lot of good things about “How to 
Think Like a Computer Scientist”. You won’t hurt yourself if you 
start there.

Best,

Matěj

-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.22 (GNU/Linux)

iD8DBQFS0fGP4J/vJdlkhKwRAu6TAKCCdGP9b3z2M+NJlIY4HnqZFi+v3gCfYgE0
69QHLyfyG//dFhb9pcjdoNk=
=y2k/
-END PGP SIGNATURE-
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is it better to import python modules inside function or at the top? What are the pros and cons?

2014-01-11 Thread Chris Angelico
On Sun, Jan 12, 2014 at 12:28 PM, Sam  wrote:
> I have python modules which are used only in specific functions and the 
> functions are not called all the time. Is it better to import the function 
> inside the function only or is it a better practice to always import all 
> modules at the top of the script? If I import the module inside the function, 
> will it cause a big performance hit because of the import module action that 
> gets to be called every time the function is called?
>
> What are the pros and cons of each approach?

Most of the work of importing is still going to be done only once
(after that, the import just grabs a cached reference to the same
module). It's normally clearer to import at the top of the module,
especially if you have multiple functions calling on the same module,
but there are two other concerns:

1) If the module can't be found, would you rather know as soon as your
module is loaded, or is it better to load your module without it and
then fail only when that function is called?

2) If the module takes a long time to load, would you rather pay that
cost as soon as your module is loaded, or on the first use of the
function that needs it?

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


Re: Is it better to import python modules inside function or at the top? What are the pros and cons?

2014-01-11 Thread Ned Batchelder

On 1/11/14 8:28 PM, Sam wrote:

I have python modules which are used only in specific functions and the 
functions are not called all the time. Is it better to import the function 
inside the function only or is it a better practice to always import all 
modules at the top of the script? If I import the module inside the function, 
will it cause a big performance hit because of the import module action that 
gets to be called every time the function is called?

What are the pros and cons of each approach?



Unless there's a good reason, you should import all the modules at the 
top of the file.


Reasons to import in a function:

1) if a function is only sometimes called, and the import is expensive.

2) if a function is only sometimes called, and needs a dependency that 
not all users of your package need.  For example, your library has both 
Flask and Django helper functions, and only Django users call the Django 
function, etc.


3) if you have a circular import, though that can often be fixed in 
better ways.


Note that the cost of imports is only incurred at the first import, so 
you don't have to worry about the import statement executing each time 
your function is called.  After the first import, the cost is about the 
same as a dict lookup (very fast).


--
Ned Batchelder, http://nedbatchelder.com

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


Re: Open Question - I'm a complete novice in programming so please bear with me...Is python equivalent to C, C++ and java combined?

2014-01-11 Thread Dan Stromberg
On Sat, Jan 11, 2014 at 12:07 AM, pintreo mardi  wrote:
> Hi, I've just begun to learn programming, I have an open question for the 
> group:
> Is the Python language an all in one computer language which could replace C, 
> C++, Java etc.. I only ask becuase I am starting off with python and I want 
> to learn everything in basic and advanced programming with python itself...So 
> any advice and suggestions would be more than welcome.
> Thanks!!

As others have mentioned, they're all turing-complete.  In other
words, with an infinite memory and infinite coding patience, they can
all solve the same problems.

The main distinctions, at least to my mind, are:
1) Python tends to require fewer words to solve the same problems, but
tends to be slow running.
2) C tends to be very fast running, but takes a lot of words to solve
the same problems, and is prone to hard-to-fix memory errors
3) C++ and Java aren't that different in performance today, because of
Java's good JIT.
4) Java's not great for systems programming (apparently can't detect
symlink races for example), but C, C++ and sometimes Python are.

Each language will tend to have API's (Application Programming
Interfaces) that make some classes of problems easier or harder.
API's are basically reusable code you can use to make your own
problems quicker and easier.

You probably wouldn't write an operating system kernel in Python -
it'd be too slow.  However, writing an application in Python might be
a very good use of time.

If Python proves too slow for a problem (which is uncommon), you can
rewrite small portions in C to get good performance.  Also, there is
another implementation of Python called PyPy that's much faster than
the reference implementation, which is known as CPython.

C++ and Java cover similar kinds of programming - they're both object
oriented C-like languages.  However, C++ is more prone to memory
errors than Java, and I'm told that C++ has many incompatible
implementations of fundamental things like strings.  For these
reasons, I'd recommend Java over C++ for most things (except systems
programming).

C, C++ and Java are all statically, manifestly typed.  Python is duck
typed.  These are fundamentally different approaches to program
correctness.  In C, C++ and Java, programmers tend to assume that if a
program compiles, it's working.  This is not a great assumption, but
it isn't that far off the mark, either.  Python on the other hand,
will compile a lot more programs than those that work - for this
reason, it's a very good idea to use automated tests with Python.
Automated tests are a good idea with C, C++ and Java too, just not as
crucial.

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


Re: Python 3 __bytes__ method

2014-01-11 Thread Ethan Furman

On 01/11/2014 06:19 PM, Daniel da Silva wrote:


One use case is:
Suppose you have existing function that accepts a /bytes/ object. If you 
subclass /bytes/ and want it to be guaranteed
to work with that function, you can override/__bytes__()/ to use the logistics 
of your subclass implementation.


I don't think so, for two reasons:

1) bytes objects do not have a __bytes__ method,

2) if the function is expecting a bytes object, it is unlikely to call bytes() 
on it.

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


Re: Python 3 __bytes__ method

2014-01-11 Thread Daniel da Silva
One use case is:
Suppose you have existing function that accepts a *bytes* object. If you
subclass *bytes* and want it to be guaranteed to work with that function,
you can override* __bytes__()* to use the logistics of your subclass
implementation.


On Sat, Jan 11, 2014 at 7:56 PM, Ethan Furman  wrote:

> On 01/11/2014 04:53 PM, Daniel da Silva wrote:
>
>>
>> Where did you read this? I can't find any documentation about __bytes__
>> on google.
>>
>
> http://docs.python.org/3.3/reference/datamodel.html?
> highlight=__bytes__#object.__bytes__
>
>
> --
> ~Ethan~
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


parametized unittest

2014-01-11 Thread CraftyTech
hello all,

 I'm trying parametize my unittest so that I can re-use over and over, 
perhaps in a for loop.  Consider the following:

'''
import unittest

class TestCalc(unittest.TestCase):
def testAdd(self):
self.assertEqual(7, 7, "Didn't add up")

if __name__=="__main__":
unittest.main()

'''


Simple and straight forward, but I'm trying to get to a place where I can run 
it this way:

import unittest

class TestCalc(unittest.TestCase):
def testAdd(self,var):
self.assertEqual(var, 7, "Didn't add up")

if __name__=="__main__":
unittest.main(testAdd(7))

is this possible?  I'm finding it hard to use unittest in a for loop.  Perhaps 
something like:

for val in range(25):
  self.assertEqual(val,5,"not equal)

The loop will break after the first failure.  Anyone have a good approach for 
this?  please advise.

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


Re: parametized unittest

2014-01-11 Thread Ben Finney
CraftyTech  writes:

> I'm trying parametize my unittest so that I can re-use over and over,
> perhaps in a for loop.

The ‘testscenarios’ https://pypi.python.org/pypi/testscenarios>
library allows you to define a set of data scenarios on your
FooBarTestCase and have all the test case functions in that class run
for all the scenarios, as distinct test cases.

e.g. a class with 5 scenarios defined, and 3 test case functions, will
run as 15 distinct test cases with separate output in the report.

> The loop will break after the first failure. Anyone have a good
> approach for this? please advise.

Yes, this is exactly the problem addressed by ‘testscenarios’. Enjoy it!

-- 
 \“Program testing can be a very effective way to show the |
  `\presence of bugs, but is hopelessly inadequate for showing |
_o__)  their absence.” —Edsger W. Dijkstra |
Ben Finney

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


Re: parametized unittest

2014-01-11 Thread W. Trevor King
On Sat, Jan 11, 2014 at 08:00:05PM -0800, CraftyTech wrote:
> I'm finding it hard to use unittest in a for loop.  Perhaps something like:
> 
> for val in range(25):
>   self.assertEqual(val,5,"not equal)
> 
> The loop will break after the first failure.  Anyone have a good
> approach for this?  please advise.

If Python 3.4 is an option, you can stick to the standard library and
use subtests [1].

Cheers,
Trevor

[1]: 
http://docs.python.org/3.4/library/unittest.html#distinguishing-test-iterations-using-subtests

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy


signature.asc
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: parametized unittest

2014-01-11 Thread Roy Smith
In article ,
 "W. Trevor King"  wrote:

> On Sat, Jan 11, 2014 at 08:00:05PM -0800, CraftyTech wrote:
> > I'm finding it hard to use unittest in a for loop.  Perhaps something like:
> > 
> > for val in range(25):
> >   self.assertEqual(val,5,"not equal)
> > 
> > The loop will break after the first failure.  Anyone have a good
> > approach for this?  please advise.
> 
> If Python 3.4 is an option, you can stick to the standard library and
> use subtests [1].

Or, as yet another alternative, if you use nose, you can write test 
generators.

https://nose.readthedocs.org/en/latest/writing_tests.html#test-generators
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Open Question - I'm a complete novice in programming so please bear with me...Is python equivalent to C, C++ and java combined?

2014-01-11 Thread Steve Hayes
On Sat, 11 Jan 2014 10:45:53 -0500, Roy Smith  wrote:

>In article <[email protected]>,
> pintreo mardi  wrote:
>
>> Hi, I've just begun to learn programming, I have an open question for the 
>> group:
>> Is the Python language an all in one computer language which could replace 
>> C, 
>> C++, Java etc.. I only ask becuase I am starting off with python and I want 
>> to learn everything in basic and advanced programming with python 
>> itself...So 
>> any advice and suggestions would be more than welcome.
>> Thanks!!
>
>That's a really hard question to answer, or at least to answer well.
>
>At a theoretical level, when you ask, "Is Python equivalent to C, C++ 
>and Java", the answer is "yes".  In computer science, programming 
>languages are classified by whether they are "Turing Complete" or not 
>(google that for more info).  In theory, any Turing Complete language is 
>capable of writing all programs which can be written in any other Turing 
>Complete language.  All of the languages you mention are Turing 
>Complete, so, theoretically, they are all equivalent.
>
>But, at a more practical level, some languages are easier to learn, some 
>run faster, some are more portable, some are more convenient to use, 
>etc.  If I had to rank the languages you mention by a few categories, 
>I'd say something like:
>

I think the significant thing is that some languages are easier to use for
some things than for others. Though you can use any language to write any kind
of program in theory, in practice some languages are designed to write certain
kinds of programs more easily and more quickly -- Prolog for AI programs, for
example.

So the question is, which kinds of programs is Python best for?

I'm a novice at it, so it's a question that concerns me. From what I've heard
and read, it seems to be a fairly good general-purpose language, and it seems
to be most used for writing web applications (though that is not something I
am particularly interested in). 


-- 
Steve Hayes from Tshwane, South Africa
Web:  http://www.khanya.org.za/stevesig.htm
Blog: http://khanya.wordpress.com
E-mail - see web page, or parse: shayes at dunelm full stop org full stop uk
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python first project

2014-01-11 Thread ngangsia akumbo
On Saturday, January 11, 2014 11:10:20 PM UTC+1, Dennis Lee Bieber wrote:
> On Sat, 11 Jan 2014 09:55:57 -0800 (PST), ngangsia akumbo
> 
>  declaimed the following:


What options do you think i can give the Ceo. Because from what you have 
outline, i think i will like to follow your advice. 

If it is just some recording data stuff then some spreadsheet can do the work.

>From all indication it is a very huge project.

How much do you thing all this will cost if we were to put the system all 
complete. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 __bytes__ method

2014-01-11 Thread Ethan Furman

On 01/11/2014 08:56 PM, Daniel da Silva wrote:


I agree with you that realistic use cases are hard to think of.

Does that answer your question better?


Well, since I was asking if anybody was already using the feature, no.  ;)

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


Re: Open Question - I'm a complete novice in programming so please bear with me...Is python equivalent to C, C++ and java combined?

2014-01-11 Thread Chris Angelico
On Sun, Jan 12, 2014 at 4:08 PM, Steve Hayes  wrote:
> So the question is, which kinds of programs is Python best for?
>
> I'm a novice at it, so it's a question that concerns me. From what I've heard
> and read, it seems to be a fairly good general-purpose language, and it seems
> to be most used for writing web applications (though that is not something I
> am particularly interested in).

Python puts heavy focus on code readability (which also means it's
easy to write). So it gains you hugely for small scripts, less so for
things that need to run millions of times a second.

Python has a variety of libraries that make it well suited to internet
applications (as server or as client).

Python, especially as of version 3.3, is superb at handling
internationalization, Unicode, and related messes - you can sort out
files of different encodings and rewrite them in something consistent
(eg UTF-8). It may seem a bit harder at first, as you're forced to
think about the meaning of bytes and what's text and so on, but it's
worth it.

Python is NOT good at massively parallel numerical calculations on
its own. But there are libraries that can do that sort of thing for
you (NumPy, SciPy); I've no idea how good they are because I neither
use them nor write code that would benefit from them, but they're
extremely popular and well-used.

As a general rule, if your program is likely to spend most of its time
waiting (for the disk, the network, the user, etc), then Python is
probably at least as good a choice as C, Java, or any other language,
and the question will come down to library support and such.

Python is also an excellent "super pocket calculator". The
reasonably-compact notation for aggregate operations (list
comprehensions and such) lets you work with a functional programming
style, and you can use step-by-step imperative programming in the same
way. Want to calculate the average result of rolling six six-sided
dice, and discarding any results below 14? Try this:

http://www.kickstarter.com/projects/916188323/doublesix-dice-roll-better/comments?cursor=5623335#comment-5623334

(BTW, is there no better notation than six nested for/range for doing
6d6? I couldn't think of one off-hand, but it didn't really much
matter anyway.)

The incremental execution of Python's interactive interpreter (REPL)
is extremely convenient for this. I personally like using IDLE for
this, as (unlike command-line Python) it will recall and edit an
entire suite, rather than one line at a time. Extremely handy.

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


Re: python first project

2014-01-11 Thread Chris Angelico
On Sun, Jan 12, 2014 at 4:14 PM, ngangsia akumbo  wrote:
> What options do you think i can give the Ceo. Because from what you have 
> outline, i think i will like to follow your advice.
>
> If it is just some recording data stuff then some spreadsheet can do the work.
>
> From all indication it is a very huge project.
>
> How much do you thing all this will cost if we were to put the system all 
> complete.

If you currently do all your bills and things on paper, then this job
is going to be extremely daunting. Even if you don't write a single
line of code (ie you buy a ready-made system), you're going to have to
convert everybody to doing things the new way. In that case, I would
recommend getting some people together to discuss exactly what you
need to do, and then purchase an accounting, warehousing, or inventory
management system, based on what you actually need it to do.

On the other hand, if it's already being done electronically, your job
is IMMENSELY easier. Easier, but more complex to describe, because
what you're really asking for is a program that will get certain data
out of your accounting/inventory management system and display it. The
difficulty of that job depends entirely on what you're using for that
data entry.

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


Re: Python 3 __bytes__ method

2014-01-11 Thread Daniel da Silva
On Sat, Jan 11, 2014 at 9:44 PM, Ethan Furman  wrote:

> On 01/11/2014 06:19 PM, Daniel da Silva wrote:
>
>>
>> One use case is:
>> Suppose you have existing function that accepts a /bytes/ object. If you
>> subclass /bytes/ and want it to be guaranteed
>> to work with that function, you can override/__bytes__()/ to use the
>> logistics of your subclass implementation.
>>
>
> I don't think so, for two reasons:
>
> 1) bytes objects do not have a __bytes__ method,
>
> 2) if the function is expecting a bytes object, it is unlikely to call
> bytes() on it.


In general __typename__() methods are for explicit typename(obj)
conversion. There is __int__(), __str__(), etc. They are what is behind
int('3') == 3 and str(4) == '4'. If for no other reason, __bytes__() is
there for symmetry. I agree with you that realistic use cases are hard to
think of.

Does that answer your question better?

All the best,
Daniel
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python first project

2014-01-11 Thread ngangsia akumbo
On Sunday, January 12, 2014 7:04:04 AM UTC+1, Chris Angelico wrote:
> On Sun, Jan 12, 2014 at 4:14 PM, ngangsia akumbo  wrote:

i am not sure i will give up, i will start with a small app for stock registry.
>From there i think the others will come latter.

>From the info u have given me , i will continue from there on.
So now is i will try to build a small app for stock registry

may be u can still give me some tips on that
-- 
https://mail.python.org/mailman/listinfo/python-list


'Straße' ('Strasse') and Python 2

2014-01-11 Thread wxjmfauth
>>> sys.version
2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
>>> s = 'Straße'
>>> assert len(s) == 6
>>> assert s[5] == 'e'
>>> 

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