[Tutor] I have a problem with def
it doesn't work, you are suppsed to declare a function as def func() and it comes back as: File "", line 1 def func() ^ SyntaxError: invalid syntax that is not expected I would also expect def to turn red because it is a keyword in Python, but that doesn't happen, anyone else having this problem Anyone know what I should do or look for ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] startin python
SIRS I am an absolute beginner in PYTHON so I would like to ask your advice regarding the appropriate compilers. What would be the best compiler for a beginner? What would be the best compiler for writing a combined code PYTHON and C? 3)I need PYTHON for the following purposes: A)EMBEDDED SYSTEM PROGRAMMING B)SCIENTIFIC PROGRAMMING C)IMAGE AND VIDEO PROCESSING D)DATA VISUALIZATION E)REAL TIME GUI F)DESIGNING PC BASED MEASURING SYSTEMS (like pc dso,logic analyzer,ect) Please let me know what kind of PYTHON libraries wouldthe most adequate for these tasks and where it would be possible to download them and if possibe direct me to the corresponding PYTHON literature Thank you for your collaboration JEOVANNY VITERI ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] I have a problem with def
On 22/02/18 22:16, David Bauer wrote: it doesn't work, you are suppsed to declare a function as def func() and it comes back as: File "", line 1 def func() ^ SyntaxError: invalid syntax that is not expected I would also expect def to turn red because it is a keyword in Python, but that doesn't happen, anyone else having this problem Anyone know what I should do or look for The colon is missing. def func(): ... -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] startin python
Hello, and see my comments below. On Thu, Feb 22, 2018 at 10:34:53PM -0500, gonzales huerta wrote: > SIRS > I am an absolute beginner in PYTHON so I would like to ask your > advice regarding the appropriate compilers. > What would be the best compiler for a beginner? Python is normally described as using an interpreter. (Technically it has a compiler, but it is a byte-code compiler, it doesn't generate machine code.) Stick to the standard Python 3 interpreter unless you need to run Java libraries or run under .Net, > What would be the best compiler for writing a combined code PYTHON and C? There's no such thing as a combined Python and C compiler, although Cython comes close. But I would say Cython is probably not for beginners, if you don't know Python, you'll struggle with Cython. > 3)I need PYTHON for the following purposes: > A)EMBEDDED SYSTEM PROGRAMMING > B)SCIENTIFIC PROGRAMMING > C)IMAGE AND VIDEO PROCESSING > D)DATA VISUALIZATION > E)REAL TIME GUI > F)DESIGNING PC BASED MEASURING SYSTEMS (like pc dso,logic analyzer,ect) > Please let me know what kind of PYTHON libraries wouldthe most > adequate for these tasks and where it would be possible to download > them and if possibe direct me to the corresponding PYTHON literature Do you know how to use a search engine? https://duckduckgo.com/html/?q=scientific%20python%20ide For embedded programming, you will probably want to use MicroPython instead of the regular Python interpreter. You could try a commercial IDE like Enthought Canopy, PyCharm, ActiveState's Python (I think this one is called Anaconda?), or the Wing Python IDE. https://wingware.com/ A free alternative is Spyder, although this is the only one I've actually used and I found it to be unusably slow on my computer. Another alternative is iPython, which lets you write notebooks rather like Mathematica. It is not helpful to ask what libraries you should use when we don't know what you will be doing, but in general, the most common third-party libraries for scientific programming include: numpy scipy pandas matplotlib and probably a thousand others. -- Steve ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Doubt in list comprehension
Hi All, I am a beginner programmer and i wrote a small program (as per a assignment i saw) as below: newlist = [] for a in range(2,5): for b in range (0,3): newlist.append([a]) a = a + 1 print(newlist) it gives the expected output as below: [[2], [3], [4], [3], [4], [5], [4], [5], [6]] but when i try list comprehension i am not able to get it correctcan someone please suggest where the (a=a+1) should be placed in a list comprehension Thanks, Vinod Bhaskaran ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Doubt in list comprehension
vinod bhaskaran wrote: > Hi All, > > I am a beginner programmer and i wrote a small program (as per a > assignment i saw) as below: > > newlist = [] > for a in range(2,5): > for b in range (0,3): > newlist.append([a]) > a = a + 1 > print(newlist) > > it gives the expected output as below: > [[2], [3], [4], [3], [4], [5], [4], [5], [6]] > > but when i try list comprehension i am not able to get it correctcan > someone please suggest where the (a=a+1) should be placed in a list > comprehension You canot sneak a statement like > a = a + 1 into a list comprehension, you have to modify the expressions. Given [[...] for a in range(2, 5) for b in range(3)] what expression replacing the ... would give the expected result? Hint: it depends on both a and b. Once you have figured it out you can try and reshuffle it a bit into [[b] for a in range(2, 5) for b in range(...)] ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] I have a problem with def
On Feb 23, 2018 3:58 AM, "David Bauer" wrote: > > it doesn't work, you are suppsed to declare a function as def func() and it > comes back as: > > File "", line 1 > def func() > ^ > SyntaxError: invalid syntax > > that is not expected I would also expect def to turn red because it is a > keyword in Python, but that doesn't happen That is an effect of syntax coloring. That in turn depends on what you're using to enter your program. Please tell us what you are using to enter your program and we can help with that. anyone else having this > problem Anyone know what I should do or look for > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Doubt in list comprehension
On 02/23/2018 06:40 AM, Peter Otten wrote: > vinod bhaskaran wrote: > >> Hi All, >> >> I am a beginner programmer and i wrote a small program (as per a >> assignment i saw) as below: >> >> newlist = [] >> for a in range(2,5): >> for b in range (0,3): >> newlist.append([a]) >> a = a + 1 >> print(newlist) >> >> it gives the expected output as below: >> [[2], [3], [4], [3], [4], [5], [4], [5], [6]] >> >> but when i try list comprehension i am not able to get it correctcan >> someone please suggest where the (a=a+1) should be placed in a list >> comprehension > > You canot sneak a statement like > >> a = a + 1 I would go further: you should not be sneaking it into your original code either - it's not a great idea to modify the iteration variable while inside the loop. It works this time because you're iterating over a list that has been made for you by range: >>> print(range(2,5)) [2, 3, 4] so second time through 'a' gets the second value in the list and it doesn't break things that you changed 'a' while it was in use, but it's a bad habit to get into - if you use the same concept in a while loop, say, you will get unpleasant surprises. So to further Peter's suggestion - try to figure out how to stop doing that in your inner loop, and it will be much more clear what to do in the comprehension form. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] startin python
Just a quick clarification: > You could try a commercial IDE like Enthought Canopy, PyCharm, > ActiveState's Python (I think this one is called Anaconda?), or the Wing > Python IDE. ActiveState's Python is ActivePython while Anaconda is a separate distribution, also very useful. Both orient themselves now as being a "Data Science Platform" - more familiar with Anaconda, it's nice because it gives you lots of the scientific, etc. stuff installed without problems, and the installer makes adding more fairly easy. I believe ActivePython now is similar. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] I have a problem with def
I don't what you are doing but it should be at least def func(): notice the colon at the end. Johnf On 02/22/2018 02:16 PM, David Bauer wrote: it doesn't work, you are suppsed to declare a function as def func() and it comes back as: File "", line 1 def func() ^ SyntaxError: invalid syntax that is not expected I would also expect def to turn red because it is a keyword in Python, but that doesn't happen, anyone else having this problem Anyone know what I should do or look for ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Doubt in list comprehension
Thanks Peter. Shall figure it out with the below hint. I had a hunch am wrong but was not sure where to put in . Thanks, Vinod Bhaskaran On Fri, Feb 23, 2018, 7:11 PM Peter Otten <__pete...@web.de> wrote: > vinod bhaskaran wrote: > > > Hi All, > > > > I am a beginner programmer and i wrote a small program (as per a > > assignment i saw) as below: > > > > newlist = [] > > for a in range(2,5): > > for b in range (0,3): > > newlist.append([a]) > > a = a + 1 > > print(newlist) > > > > it gives the expected output as below: > > [[2], [3], [4], [3], [4], [5], [4], [5], [6]] > > > > but when i try list comprehension i am not able to get it correctcan > > someone please suggest where the (a=a+1) should be placed in a list > > comprehension > > You canot sneak a statement like > > > a = a + 1 > > into a list comprehension, you have to modify the expressions. Given > > [[...] for a in range(2, 5) for b in range(3)] > > what expression replacing the ... would give the expected result? > > Hint: it depends on both a and b. > > Once you have figured it out you can try and reshuffle it a bit into > > [[b] for a in range(2, 5) for b in range(...)] > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] startin python
Thank you very much for the tips I hope we will be in touch in the futire jeovanny 2018-02-23 5:48 GMT-05:00, Steven D'Aprano : > Hello, and see my comments below. > > On Thu, Feb 22, 2018 at 10:34:53PM -0500, gonzales huerta wrote: >> SIRS >> I am an absolute beginner in PYTHON so I would like to ask your >> advice regarding the appropriate compilers. >> What would be the best compiler for a beginner? > > Python is normally described as using an interpreter. > > (Technically it has a compiler, but it is a byte-code compiler, it > doesn't generate machine code.) > > Stick to the standard Python 3 interpreter unless you need to run Java > libraries or run under .Net, > > >> What would be the best compiler for writing a combined code PYTHON and C? > > There's no such thing as a combined Python and C compiler, although > Cython comes close. But I would say Cython is probably not for > beginners, if you don't know Python, you'll struggle with Cython. > > >> 3)I need PYTHON for the following purposes: >> A)EMBEDDED SYSTEM PROGRAMMING >> B)SCIENTIFIC PROGRAMMING >> C)IMAGE AND VIDEO PROCESSING >> D)DATA VISUALIZATION >> E)REAL TIME GUI >> F)DESIGNING PC BASED MEASURING SYSTEMS (like pc dso,logic analyzer,ect) >> Please let me know what kind of PYTHON libraries wouldthe most >> adequate for these tasks and where it would be possible to download >> them and if possibe direct me to the corresponding PYTHON literature > > Do you know how to use a search engine? > > https://duckduckgo.com/html/?q=scientific%20python%20ide > > For embedded programming, you will probably want to use MicroPython > instead of the regular Python interpreter. > > You could try a commercial IDE like Enthought Canopy, PyCharm, > ActiveState's Python (I think this one is called Anaconda?), or the Wing > Python IDE. > > https://wingware.com/ > > A free alternative is Spyder, although this is the only one I've > actually used and I found it to be unusably slow on my computer. > > Another alternative is iPython, which lets you write notebooks rather > like Mathematica. > > It is not helpful to ask what libraries you should use when we don't > know what you will be doing, but in general, the most common third-party > libraries for scientific programming include: > > numpy > scipy > pandas > matplotlib > > > and probably a thousand others. > > > > -- > Steve > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] startin python
On 23/02/18 03:34, gonzales huerta wrote: > What would be the best compiler for writing a combined code PYTHON and C? There are several ways to do this and it depends on your application which is most practical. If w assume yyou want to access the C code from Python then: 1) Write a Python module in C and then import it into Python 2) Write a C library and call it from Python (using the ctypes Python module for example) 3) Write a C program and then call it from Python using the subprocess library. These are in reverse order of difficulty (ie 3 is easiest). 1 is best if you need to access the C code from several Pyhon programs. 2 is best if you need to access the C code from both Python and C 3 is best if you only have a few high-level tasks to perform in C, and want the simplest integration. If you want to access Pyhon code from C then you need 1) Embed the Python intetrpreter in your C code ande call it using the Python API. 2) Write a Python service framework that can be called from C using fork/system or whatever 3) Create a Python http server that you can call from C (or any other language) using AJAX 1) Most difficult but best performance and loweset resource usage, 2) Relatively easy but resource heavy 3) Easiest if you know web technology and best if you might need several programs to access it, but probably slowest too. There are other options too (Steve mentioned Cython and there are tools like Boost too) > 3)I need PYTHON for the following purposes: > A)EMBEDDED SYSTEM PROGRAMMING See the comments above re integrating C and Python. > B)SCIENTIFIC PROGRAMMING > C)IMAGE AND VIDEO PROCESSING > D)DATA VISUALIZATION Down to here suggests you get a distribution with all the SciPy stuff included such as Anaconda or Entropy. Anaconda seems to be the most popular so probably has best support network. > E)REAL TIME GUI That's pretty much a contradiction in terms, GUIs are hardly ever truly real-time. However Python can create GUIs that talk to real-time back end processes or threads. > F)DESIGNING PC BASED MEASURING SYSTEMS (like pc dso,logic analyzer,ect) I'm not familiar with these so can't comment > Please let me know what kind of PYTHON libraries If you get Anaconda etc then most libraries you need will be included. That then leaves application specific libraries that you would need to describe your needs in more detail for anyone to give recommendations. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor