Re: Using generator expressions

2023-09-25 Thread Chris Angelico via Python-list
On Tue, 26 Sept 2023 at 01:39, Jonathan Gossage via Python-list wrote: > > Many thanks, all. It turned out that my problem was not fully understanding > the use and power of the unpack operator *. Using it to activate my > generator made things start to work. I changed the line whe

Re: Using generator expressions

2023-09-25 Thread Jonathan Gossage via Python-list
Many thanks, all. It turned out that my problem was not fully understanding the use and power of the unpack operator *. Using it to activate my generator made things start to work. I changed the line where I invoked the generator to: y = test1(*(a for a in st)) adding the unpack operator. On

Re: Using generator expressions

2023-09-25 Thread Thomas Passin via Python-list
On 9/25/2023 10:15 AM, Jonathan Gossage via Python-list wrote: I am having a problem using generator expressions to supply the arguments for a class instance initialization. The following example shows the problem: class test1(object): def __init__(self, a, b): self.name = a

Re: Using generator expressions

2023-09-25 Thread Dom Grigonis via Python-list
y = test1(*[a for a in st]) y = test1(*st) Maybe any of these would be ok for you? Regards, DG > On 25 Sep 2023, at 17:15, Jonathan Gossage via Python-list > wrote: > > I am having a problem using generator expressions to supply the arguments > for a class instance init

Using generator expressions

2023-09-25 Thread Jonathan Gossage via Python-list
I am having a problem using generator expressions to supply the arguments for a class instance initialization. The following example shows the problem: class test1(object): def __init__(self, a, b): > self.name = a self.value = b st = 'Programming Renaissance, An

Re: Creating lambdas inside generator expression

2022-06-30 Thread Peter Otten
On 29/06/2022 23:17, Chris Angelico wrote: On Thu, 30 Jun 2022 at 02:49, Johannes Bauer wrote: But now consider what happens when we create the lambdas inside a list comprehension (in my original I used a generator expresison, but the result is the same). Can you guess what happens when we

Re: Creating lambdas inside generator expression

2022-06-29 Thread Chris Angelico
On Thu, 30 Jun 2022 at 02:49, Johannes Bauer wrote: > But now consider what happens when we create the lambdas inside a list > comprehension (in my original I used a generator expresison, but the > result is the same). Can you guess what happens when we create conds > like thi

Re: Creating lambdas inside generator expression

2022-06-29 Thread Antoon Pardon
sg: msg.hascode("foo"), lambda msg: msg.hascode("bar"), ] msg = Msg() print(conds[0](msg)) print(conds[1](msg)) It works perfectly and does exactly what it looks like. The output is: Check for foo False Check for bar False But now consider what happens when we create the l

Creating lambdas inside generator expression

2022-06-29 Thread Johannes Bauer
The output is: Check for foo False Check for bar False But now consider what happens when we create the lambdas inside a list comprehension (in my original I used a generator expresison, but the result is the same). Can you guess what happens when we create conds like this? conds = [ lambda msg: m

Re: Creating lambdas inside generator expression

2022-06-29 Thread Johannes Bauer
sg)) > print(conds[1](msg)) > > > > It works perfectly and does exactly what it looks like. The output is: > > Check for foo > False > Check for bar > False > > But now consider what happens when we create the lambdas inside a list > comprehension (in m

Re: Subtle difference between any(a list) and any(a generator) with Python 3.9

2021-07-29 Thread Chris Angelico
On Fri, Jul 30, 2021 at 5:40 AM Terry Reedy wrote: > Since the 'two ways' involve the new :=, I have no idea what 'two ways' > and 'same result' you mean before :=. > I'm not sure, but I think that a lot of people read patch notes as if they say "this is how everyone needs to do things now", and

Re: Subtle difference between any(a list) and any(a generator) with Python 3.9

2021-07-29 Thread Terry Reedy
On 7/29/2021 5:39 AM, Unknown wrote: Hello Reading PEP572 about Python 3.9 assignment expressions, I discovered a subtle difference between any(a list) and any(a generator) see: >>> lines = ["azerty", "#qsdfgh", "wxcvbn"] >>> any((comment

Re: Subtle difference between any(a list) and any(a generator) with Python 3.9

2021-07-29 Thread Chris Angelico
On Thu, Jul 29, 2021 at 7:49 PM ast wrote: > > Hello > > Reading PEP572 about Python 3.9 assignment expressions, > I discovered a subtle difference between any(a list) > and any(a generator) > > see: > > >>> lines = ["azerty", "#qsdfgh",

Subtle difference between any(a list) and any(a generator) with Python 3.9

2021-07-29 Thread ast
Hello Reading PEP572 about Python 3.9 assignment expressions, I discovered a subtle difference between any(a list) and any(a generator) see: >>> lines = ["azerty", "#qsdfgh", "wxcvbn"] >>> any((comment := line).startswith('#') for li

Re: Automatically advancing a bi-directional generator to the point of accepting a non-None value?

2020-11-22 Thread Dieter Maurer
Go Luhng wrote at 2020-11-21 14:30 -0500: >Suppose we write a very simple bi-directional generator in Python: > >def share_of_total(): >s = 0 >new_num = 0 >while True: >new_num = yield new_num / (s or 1) >s += new_num

Automatically advancing a bi-directional generator to the point of accepting a non-None value?

2020-11-21 Thread Go Luhng
Suppose we write a very simple bi-directional generator in Python: def share_of_total(): s = 0 new_num = 0 while True: new_num = yield new_num / (s or 1) s += new_num share_calculator = share_of_total() next(share_calculator) # Without

Re: Why is a generator expression called a expression?

2020-04-21 Thread Chris Angelico
On Wed, Apr 22, 2020 at 6:12 AM Barry Scott wrote: > > > > > On 20 Apr 2020, at 10:29, Veek M wrote: > > > > On Mon, 20 Apr 2020 19:19:31 +1000, Chris Angelico wrote: > > > >> In the case of a genexp, the expression has a value which is a generator &g

Re: Why is a generator expression called a expression?

2020-04-21 Thread Barry Scott
> On 20 Apr 2020, at 10:29, Veek M wrote: > > On Mon, 20 Apr 2020 19:19:31 +1000, Chris Angelico wrote: > >> In the case of a genexp, the expression has a value which is a generator >> object. When you pass that to all(), it takes it and then iterates over > >

Re: Why is a generator expression called a expression?

2020-04-21 Thread Pieter van Oostrum
Veek M writes: > The docs state that a expression is some combination of value, operator, > variable and function. Also you cannot add or combine a generator > expression with a value as you would do with 2 + 3 + 4. For example, > someone on IRC suggested this > all(a == 

Re: Why is a generator expression called a expression?

2020-04-20 Thread Chris Angelico
On Mon, Apr 20, 2020 at 8:26 PM Veek M wrote: > > but one can do the following > (x for x in 'apple').next() * 2 > > def foo(): >(yield 2) > foo().next() * 3 > > (lambda x: 2)()*4 > > generator expr, yield expr, lambda expression > all requ

Re: Why is a generator expression called a expression?

2020-04-20 Thread Veek M
but one can do the following (x for x in 'apple').next() * 2 def foo(): (yield 2) foo().next() * 3 (lambda x: 2)()*4 generator expr, yield expr, lambda expression all require some modification (insertion of a .next or explicit () so it's quite confusing.. expressio

Re: Why is a generator expression called a expression?

2020-04-20 Thread DL Neil via Python-list
On 20/04/20 9:19 PM, Chris Angelico wrote: On Mon, Apr 20, 2020 at 6:51 PM Veek M wrote: The docs state that a expression is some combination of value, operator, variable and function. Also you cannot add or combine a generator expression with a value as you would do with 2 + 3 + 4. For

Re: Why is a generator expression called a expression?

2020-04-20 Thread Veek M
Also you will note, one can do: ( 2 if 3 > 2 else 4 ) + 4 so the () is just for precedence but otherwise a Conditional Expression works as expected by returning a value to be added to + 4. -- https://mail.python.org/mailman/listinfo/python-list

Re: Why is a generator expression called a expression?

2020-04-20 Thread Veek M
On Mon, 20 Apr 2020 19:19:31 +1000, Chris Angelico wrote: > In the case of a genexp, the expression has a value which is a generator > object. When you pass that to all(), it takes it and then iterates over but an object is NOT THE SAME as it's value! '2' is an object whi

Re: Why is a generator expression called a expression?

2020-04-20 Thread Chris Angelico
On Mon, Apr 20, 2020 at 6:51 PM Veek M wrote: > > The docs state that a expression is some combination of value, operator, > variable and function. Also you cannot add or combine a generator > expression with a value as you would do with 2 + 3 + 4. For example, > someone on IRC

Why is a generator expression called a expression?

2020-04-20 Thread Veek M
The docs state that a expression is some combination of value, operator, variable and function. Also you cannot add or combine a generator expression with a value as you would do with 2 + 3 + 4. For example, someone on IRC suggested this all(a == 'a' for a in 'apple') but

Re: Is there a piece of code ('inspect') that displays all/most of the attributes/methods in a frame, traceback, generator object in a readable fashion

2019-11-19 Thread Antoon Pardon
Maybe you should have a look at: http://code.activestate.com/recipes/52215-get-more-information-from-tracebacks/ On 19/11/19 15:08, Veek M wrote: > Basically I want to call a method and pretty print the object contents > for some code I'm playing with. > > Instead of manually writing all this cru

Is there a piece of code ('inspect') that displays all/most of the attributes/methods in a frame, traceback, generator object in a readable fashion

2019-11-19 Thread Veek M
Basically I want to call a method and pretty print the object contents for some code I'm playing with. Instead of manually writing all this crud. Something like a python object explorer. def foo(a, x = 10): 2 + 2 def bar(): pass class A: pass class Foo(A, object): def __ini

Re: Asking for feedback: Mirror GitHub issues with a static site generator

2019-10-19 Thread Chris Angelico
t; > that the issues themselves are covered by the AGPL, or are they > > counted as data? > > Oh, no! Of course issues and comments are data and are not covered by AGPL. > Only the application itself is covered, even though AGPL for a static site > generator is almost unenforcea

Re: Asking for feedback: Mirror GitHub issues with a static site generator

2019-10-19 Thread Vitaly Potyarkin
ourse issues and comments are data and are not covered by AGPL. Only the application itself is covered, even though AGPL for a static site generator is almost unenforceable, because of the middleware loophole. Pelican - static site generator I base my work on - uses AGPL for their source code, and no on

Re: Asking for feedback: Mirror GitHub issues with a static site generator

2019-10-18 Thread Chris Angelico
> static site generator, it provides Makefiles for quickly starting with demo > configuration. A good plan. I'm personally (and currently) happy with GitHub, but I'm aware that not everyone is, and of course we don't know what the future holds. > What do you think of the pro

Asking for feedback: Mirror GitHub issues with a static site generator

2019-10-18 Thread Vitaly Potyarkin
Hello, I'm looking to get some feedback on my project. It's a backup mechanism for GitHub issues and pull requests that creates human-readable issue archives in HTML - ready to be served as a static web site. The project is written in Python and works by extending Pelican static site

Re: generator to write N lines to file

2019-06-24 Thread Sayth Renshaw
> To get the individual lines you have to yield them > > for line in lines_gen: > yield line > > This can be rewritten with some syntactic sugar as > > yield from lines_gen > > > for line in getWord(fileName, 5): > > with open(dumpName, 'a') as f: > >

Re: generator to write N lines to file

2019-06-23 Thread Peter Otten
Sayth Renshaw wrote: > Afternoon > > Trying to create a generator to write the first N lines of text to a file. > However, I keep receiving the islice object not the text, why? > > from itertools import islice > > fileName = dir / "7oldsamr.txt" > dumpNam

generator to write N lines to file

2019-06-23 Thread Sayth Renshaw
Afternoon Trying to create a generator to write the first N lines of text to a file. However, I keep receiving the islice object not the text, why? from itertools import islice fileName = dir / "7oldsamr.txt" dumpName = dir / "dump.txt" def getWord(infile, lineNum):

Generator definition syntax (was: Syntax for one-line "nonymous" functions)

2019-04-02 Thread Alexey Muranov
On mar., Apr 2, 2019 at 4:31 AM, python-list-requ...@python.org wrote: Re: ">> Neither i like how a function magically turns into a generator if the keyword `yield` appears somewhere within its definition. I agree, there should have been a required syntactic element on the &qu

Re: Generator question

2019-03-14 Thread Pierre Reinbold
that!). So if I "unfold" the generator expression, using default values for both iterables, I get this : def flat_gen_cat_prod(lists): solutions = [[]] for a_list in lists: def new_solutions(l=a_list, s=solutions): for part_sol in s: f

Re: Generator question

2019-03-14 Thread Pierre Reinbold
the >> loop, like when you use the classic default value argument trick with >> lambdas (damn, I should have thought of that!). So if I "unfold" the >> generator expression, using default values for both iterables, I get this >> : >> >> def flat_gen_cat_pro

Re: Generator question

2019-03-14 Thread Peter Otten
ment trick with > lambdas (damn, I should have thought of that!). So if I "unfold" the > generator expression, using default values for both iterables, I get this > : > > def flat_gen_cat_prod(lists): > solutions = [[]] > for a_list in lists: > def new_so

Re: Generator question

2019-03-14 Thread Pierre Reinbold
that!). So if I "unfold" the generator expression, using default values for both iterables, I get this : def flat_gen_cat_prod(lists): solutions = [[]] for a_list in lists: def new_solutions(l=a_list, s=solutions): for part_sol in s: f

Re: Generator question

2019-03-13 Thread Ian Kelly
address 22 and the one at address 37: 4 22 LOAD_CLOSURE 0 (a_list) 37 LOAD_FAST 1 (solutions) The value of solutions is passed directly to the generator as an argument, which is the reason why building the generator up iteratively like this works at

Generator question

2019-03-13 Thread Pierre Reinbold
Dear all, I want to implement a function computing the Cartesian product if the elements of a list of lists, but using generator expressions. I know that it is already available in itertools but it is for the sake of understanding how things work. I already have a working recursive version, and

Re: Problem : Generator

2019-02-16 Thread Prahallad Achar
Yupee.. Thanks for the knowledge sharing. Regards Prahallad On Sat, 16 Feb 2019, 12:18 dieter Prahallad Achar writes: > > > I get list object instead gen obj > > If you have a list "l" and want a generator, you can use >( x for x in l) > or simpler "ite

Re: Problem : Generator

2019-02-16 Thread Prahallad Achar
Woww.. This solves the problem.. Thank you very much On Sat, 16 Feb 2019, 12:54 Avi Gross Just want to point out you can make any function into a generator by having > a yield statement like this: > > >>> def previous(listing): > while listing: yield listing.pop()

RE: Problem : Generator

2019-02-15 Thread Avi Gross
Just want to point out you can make any function into a generator by having a yield statement like this: >>> def previous(listing): while listing: yield listing.pop() >>> for num in previous([1,2,3,4]): print(num) 4 3 2 1 The above is an EXAMPLE, not a part

Re: Problem : Generator

2019-02-15 Thread dieter
Prahallad Achar writes: > I get list object instead gen obj If you have a list "l" and want a generator, you can use ( x for x in l) or simpler "iter(l)" - which gives you an interator over "l". An "iterator" is slightly more general than a gen

Re: Problem : Generator

2019-02-15 Thread jfong
> > > Rever_gen = ( x*x for x in list1, reversed = True) > > > > > > Rever_gen gets generator object and iterating it now gets reverse order.. > > > > > > Am I correct here? Suggest me > > > > > > > How about reversed(list1) ? >

Re: Problem : Generator

2019-02-15 Thread Prahallad Achar
I get list object instead gen obj On Fri, 15 Feb 2019, 13:57 Chris Angelico On Fri, Feb 15, 2019 at 6:57 PM Prahallad Achar > wrote: > > > > How about this > > List1=[ 1,2,3,4] > > Rever_gen = ( x*x for x in list1, reversed = True) > > > > Rever_gen get

Re: Problem : Generator

2019-02-15 Thread Chris Angelico
On Fri, Feb 15, 2019 at 6:57 PM Prahallad Achar wrote: > > How about this > List1=[ 1,2,3,4] > Rever_gen = ( x*x for x in list1, reversed = True) > > Rever_gen gets generator object and iterating it now gets reverse order.. > > Am I correct here? Suggest me > How abou

Re: Problem : Generator

2019-02-14 Thread Prahallad Achar
How about this List1=[ 1,2,3,4] Rever_gen = ( x*x for x in list1, reversed = True) Rever_gen gets generator object and iterating it now gets reverse order.. Am I correct here? Suggest me On Fri, 15 Feb 2019, 12:33 dieter Prahallad Achar writes: > > How to implement reverse generator

Re: Problem : Generator

2019-02-14 Thread dieter
Prahallad Achar writes: > How to implement reverse generator A generator generates a sequence of values. The notion "reverse generator" suggests that you have a sequence of values and want to produce it in reverse order. This is not always possible. Consider: def natural():

Re: Problem : Generator

2019-02-14 Thread Ben Finney
Prahallad Achar writes: > How to implement reverse generator Welcome to the Python forum! That sounds like an interesting problem. Can you describe it more precisely? What should a “reverse generator” actually do (and not do)? Ideally, give an example: * Some code you would maybe expect

Problem : Generator

2019-02-14 Thread Prahallad Achar
How to implement reverse generator It is only passing data in reverse or how it is Yeild always returns next value and is question valid? Thanks and Regards Prahallad -- https://mail.python.org/mailman/listinfo/python-list

Re: Generators, generator expressions, and loops

2018-11-18 Thread David Neil
Steve, On 17/11/18 03:52, Steve Keller wrote: I have looked at generators, generator expressions, and iterators and I try to get more familiar with these. 1. How would I loop over all (with no upper bound) integers or all powers of two, for example? In C it would be for (int i = 0; ; i

Re: Re: Generators, generator expressions, and loops

2018-11-16 Thread Peter via Python-list
Lovely, succinct answers. On 17/11/2018 2:44 AM, Ian Kelly wrote: On Fri, Nov 16, 2018 at 7:57 AM Steve Keller wrote: I have looked at generators, generator expressions, and iterators and I try to get more familiar with these. 1. How would I loop over all (with no upper bound) integers or

Re: Generators, generator expressions, and loops

2018-11-16 Thread Matt Wheeler
> On 16 Nov 2018, at 14:54, Steve Keller wrote: > More elegant are generator expressions but I cannot think of a way > without giving an upper limit: > >for i in (2 ** i for i in range(100)): >... > > which looks ugly. Also, the double for-loop (and

Re: Generators, generator expressions, and loops

2018-11-16 Thread Santiago Basulto
Try itertools.count() . On Fri, Nov 16, 2018 at 12:08 PM Steve Keller wrote: > Cancel ill-formated article > -- > https://mail.python.org/mailman/listinfo/python-list > -- Santiago Basulto.- Co-founder @ rmotr.com -- https://m

Re: Generators, generator expressions, and loops

2018-11-16 Thread Ian Kelly
On Fri, Nov 16, 2018 at 7:57 AM Steve Keller wrote: > > I have looked at generators, generator expressions, and iterators and > I try to get more familiar with these. > > 1. How would I loop over all (with no upper bound) integers or all > powers of two, for example? &g

Generators, generator expressions, and loops

2018-11-16 Thread Steve Keller
Cancel ill-formated article -- https://mail.python.org/mailman/listinfo/python-list

Generators, generator expressions, and loops

2018-11-16 Thread Steve Keller
I have looked at generators, generator expressions, and iterators and I try to get more familiar with these. 1. How would I loop over all (with no upper bound) integers or all powers of two, for example? In C it would be for (int i = 0; ; i++) { ... } or for (int i = 1; ; i *= 2

Generators, generator expressions, and loops

2018-11-16 Thread Steve Keller
I have looked at generators, generator expressions, and iterators and I try to get more familiar with these. 1. How would I loop over all (with no upper bound) integers or all powers of two, for example? In C it would be for (int i = 0; ; i++) { ... } or for (int i = 1; ; i *= 2

Re: Permutations using a recursive generator

2018-09-18 Thread Thomas Jollans
On 2018-09-18 17:05, ast wrote: > Le 18/09/2018 à 17:01, ast a écrit : >> Hello >> >> I found a smart and very concise code to >> generate all permutations of a list. >> I put it here if someone is interested to >> figure out how it works When you say "found a [...] code" I hope you mean "wrote a

Re: Permutations using a recursive generator

2018-09-18 Thread ast
Le 18/09/2018 à 17:01, ast a écrit : error: permut instead of S     yield from permut(li2, prefix+[elt]) -- https://mail.python.org/mailman/listinfo/python-list

Permutations using a recursive generator

2018-09-18 Thread ast
Hello I found a smart and very concise code to generate all permutations of a list. I put it here if someone is interested to figure out how it works def permut(li, prefix=[]): if len(li)==1: yield prefix + li else: for elt in li: li2 = li.copy()

Generator Comprehensions

2018-07-09 Thread Steven D'Aprano
Based on feedback from people annoyed at having to write "comprehensions and generator expressions" to refer to what ought to be a single concept, Guido has given the thumbs up for a documentation change to start referring to "generator comprehensions". https://mail.

Re: Flask test generator code review?

2018-04-30 Thread George Fischhof
2018-04-18 12:41 GMT+02:00 Albert-Jan Roskam : > Hi, > > I am writing my first unittests for a Flask app. First modest goal is to > test whether a selected subset of the templates return the expected status > 200. > I am using a nose test generator in a class for this. Is th

Flask test generator code review?

2018-04-18 Thread Albert-Jan Roskam
Hi, I am writing my first unittests for a Flask app. First modest goal is to test whether a selected subset of the templates return the expected status 200. I am using a nose test generator in a class for this. Is the code below the correct way to do this? And is there a way to dynamically set

Re: Make synchronous generator from an asynchronous generator

2018-03-16 Thread Julien Salort
Le 16/03/2018 à 16:55, Ian Kelly a écrit : Note that this function can't be called more than once, because it closes the event loop at the end. Next time you call it it will get the closed event loop and try to schedule on it and then raise an exception because it's closed. Ah ok. So, if I repl

Re: Make synchronous generator from an asynchronous generator

2018-03-16 Thread Ian Kelly
don't, and no code is > duplicated. > > > Now I wish to do the same game with a generator (which happens to be called > by the acquire_to_files_async function). So I made it into an asynchronous > generator, and it works as expected. > > My problem: how do I p

Make synchronous generator from an asynchronous generator

2018-03-16 Thread Julien Salort
game with a generator (which happens to be called by the acquire_to_files_async function). So I made it into an asynchronous generator, and it works as expected. My problem: how do I proceed if I wish to build a synchronous generator from this asynchronous generator ? (for situations

Re: Python to Julia code generator?

2018-02-21 Thread Etienne Robillard
Le 2018-02-21 à 05:27, Chris Angelico a écrit : """If you find that your production code is too slow because you’re using mutual recursion between nine different languages, blame Dan Luu for this terrible idea.""" I have... NEVER gone as far as nine. That takes the cake. In fact, I don't reca

Re: Python to Julia code generator?

2018-02-21 Thread Chris Angelico
On Wed, Feb 21, 2018 at 9:04 PM, Steven D'Aprano wrote: > On Wed, 21 Feb 2018 04:13:56 -0500, Etienne Robillard wrote: > >> Hi, >> >> Would it be possible to build a Python to Julia code generator?? >> >> i'm interested to learn Julia and would love

Re: Python to Julia code generator?

2018-02-21 Thread Etienne Robillard
I found this: https://github.com/JuliaPy/PyCall.jl Looks pretty awesome already! :-) Thx E Le 2018-02-21 à 05:04, Steven D'Aprano a écrit : On Wed, 21 Feb 2018 04:13:56 -0500, Etienne Robillard wrote: Hi, Would it be possible to build a Python to Julia code generator?? i'm int

Re: Python to Julia code generator?

2018-02-21 Thread Steven D'Aprano
On Wed, 21 Feb 2018 04:13:56 -0500, Etienne Robillard wrote: > Hi, > > Would it be possible to build a Python to Julia code generator?? > > i'm interested to learn Julia and would love to have the capacity to > embed or run native Python code in Julia.. http://blog.l

Python to Julia code generator?

2018-02-21 Thread Etienne Robillard
Hi, Would it be possible to build a Python to Julia code generator?? i'm interested to learn Julia and would love to have the capacity to embed or run native Python code in Julia.. Thx Etienne -- Etienne Robillard tkad...@yandex.com https://www.isotopesoftware.ca/ --

Re: c code generator from python

2018-02-19 Thread Stefan Behnel
bhattacharya.kush...@gmail.com schrieb am 17.01.2018 um 12:03: > Is there any python framework or any tool as which can generate C code from > python code as it is . http://cython.org/ Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: python to C code generator

2018-01-23 Thread Steven D'Aprano
On Tue, 23 Jan 2018 17:43:18 +, bartc wrote: > It wouldn't be a satisfactory way of writing C programs. So, although > I'm not that big a fan of C syntax, it might be better to write C as C, > and Python as Python, to avoid confusion.) This. The fundamental reality is that `a + b` means diff

Re: python to C code generator

2018-01-23 Thread bartc
On 23/01/2018 13:34, bartc wrote: Perhaps you simply want to use Python syntax to write C code? That would > be a different kind of translator. And a simpler one, as 'a=b+c' > translates to 'a+b+c;' in C. Or rather, 'a=b+c;' (I've written source to source translators, some of which could targe

Re: python to C code generator

2018-01-23 Thread Chris Angelico
On Wed, Jan 24, 2018 at 1:45 AM, wrote: > Hey Ally, > > Cython adds a big chunk of complexity to simple things. That's the problem. That's like saying "Unicode adds a big chunk of complexity to the simple task of translating a word from Japanese into Russian". No, it doesn't; the complexity is i

Re: python to C code generator

2018-01-23 Thread theodore . leblanc
Hey Ally, Cython adds a big chunk of complexity to simple things. That's the problem. Greetings. On 01/23/2018 01:54 PM, ally.m...@bankmail.host wrote: Have you tried cython ? On 01/23/2018 01:25 PM, kushal bhattacharya wrote: On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal bha

Re: python to C code generator

2018-01-23 Thread kushal bhattacharya
On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal bhattacharya wrote: > Hi, > Is there any python framework or any tool as which can generate C code from > python code as it is . > > Thanks, > Kushal ok so which python tool would be the best one which can be included and parameter

Re: python to C code generator

2018-01-23 Thread Andrew Z
Id go this way too. Basic C is straightforward. I usually consider learning a new "thing " if the time to support potwntially combersome solution using existing methods justifies the effort. On Jan 23, 2018 09:01, "Ned Batchelder" wrote: > On 1/23/18 8:48 AM, kushal bhattacharya wrote: > >> On

Re: python to C code generator

2018-01-23 Thread Kirill Balunov
You can look at SymPy code generator http://docs.sympy.org/latest/modules/utilities/codegen.html Perhaps this is exactly what you need. With kind regards, -gdg 2018-01-23 17:00 GMT+03:00 Ned Batchelder : > On 1/23/18 8:48 AM, kushal bhattacharya wrote: > >> On Tuesday, January 23,

Re: python to C code generator

2018-01-23 Thread Ned Batchelder
On 1/23/18 8:48 AM, kushal bhattacharya wrote: On Tuesday, January 23, 2018 at 7:05:02 PM UTC+5:30, bartc wrote: On 23/01/2018 13:23, kushal bhattacharya wrote: On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal bhattacharya wrote: Hi, Is there any python framework or any tool as

Re: python to C code generator

2018-01-23 Thread kushal bhattacharya
On Tuesday, January 23, 2018 at 7:05:02 PM UTC+5:30, bartc wrote: > On 23/01/2018 13:23, kushal bhattacharya wrote: > > On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal bhattacharya > > wrote: > >> Hi, > >> Is there any python framework or any tool as which can generate C code > >>

Re: python to C code generator

2018-01-23 Thread bartc
On 23/01/2018 13:23, kushal bhattacharya wrote: On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal bhattacharya wrote: Hi, Is there any python framework or any tool as which can generate C code from python code as it is . Thanks, Kushal yes i have but it generates a complex C co

Re: python to C code generator

2018-01-23 Thread kushal bhattacharya
On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal bhattacharya wrote: > Hi, > Is there any python framework or any tool as which can generate C code from > python code as it is . > > Thanks, > Kushal yes i have but it generates a complex C code with python dependencies.I want to c

Re: python to C code generator

2018-01-23 Thread paulina . zuniga
What about Cython? On 01/23/2018 01:25 PM, kushal bhattacharya wrote: On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal bhattacharya wrote: Hi, Is there any python framework or any tool as which can generate C code from python code as it is . Thanks, Kushal hi, I have found nu

Re: python to C code generator

2018-01-23 Thread kushal bhattacharya
On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal bhattacharya wrote: > Hi, > Is there any python framework or any tool as which can generate C code from > python code as it is . > > Thanks, > Kushal hi, I have found nuitka as asuitable candidate but it seems that nuitka doesnt ge

Re: python to C code generator

2018-01-17 Thread bartc
On 17/01/2018 11:04, kushal bhattacharya wrote: Hi, Is there any python framework or any tool as which can generate C code from python code as it is . What C code would you expect to see from this line of Python: a = b + c ? -- https://mail.python.org/mailman/listinfo/python-list

Re: python to C code generator

2018-01-17 Thread David Palao
Hi, Have a look at Cython. Best 2018-01-17 12:04 GMT+01:00 kushal bhattacharya : > Hi, > Is there any python framework or any tool as which can generate C code from > python code as it is . > > Thanks, > Kushal > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.

python to C code generator

2018-01-17 Thread kushal bhattacharya
Hi, Is there any python framework or any tool as which can generate C code from python code as it is . Thanks, Kushal -- https://mail.python.org/mailman/listinfo/python-list

c code generator from python

2018-01-17 Thread bhattacharya . kushal4
Hi, Is there any python framework or any tool as which can generate C code from python code as it is . Thanks, Kushal -- https://mail.python.org/mailman/listinfo/python-list

Re: Generator - Provide parameters to url - requests

2017-07-05 Thread Peter Otten
sounds to simple :-). > > def dates(first, numdays): > # generate datetime objects for extra clarity > # note there are no implicit arguments like `base` in your code > for _ in range(numdays): > yield first > first += ONE_DAY >

Re: Generator - Provide parameters to url - requests

2017-07-05 Thread Sayth Renshaw
Thanks. I left "base" out as i was trying to remove as much uneeded code from example as possible. I had defined it as base = datetime.datetime(2017,1,1) Reading your code this sounds to simple :-). def dates(first, numdays): # generate datetime objects for extra clarity # note ther

Re: Generator - Provide parameters to url - requests

2017-07-05 Thread Frank Millman
"Sayth Renshaw" wrote in message news:328f42bb-ba23-4199-9f3a-9ec1829bc...@googlegroups.com... Hi I am struggling to figure out how I can create a generator to provide values to my url. My url needs to insert the year month and day in the url not as params to the url. import j

Re: Generator - Provide parameters to url - requests

2017-07-05 Thread Peter Otten
Sayth Renshaw wrote: > Hi > > I am struggling to figure out how I can create a generator to provide > values to my url. My url needs to insert the year month and day in the url > not as params to the url. > > > import json > import requests > import datetime &g

Generator - Provide parameters to url - requests

2017-07-04 Thread Sayth Renshaw
Hi I am struggling to figure out how I can create a generator to provide values to my url. My url needs to insert the year month and day in the url not as params to the url. import json import requests import datetime # using this I can create a list of dates for the first 210 days of this

Re: Generator and return value

2017-06-07 Thread Ian Kelly
On Wed, Jun 7, 2017 at 10:00 AM, Rob Gaddi wrote: > > On 06/06/2017 11:13 PM, Frank Millman wrote: >> >> Hi all >> >> It would be nice to write a generator in such a way that, in addition to 'yielding' each value, it performs some additional work and

Re: Generator and return value

2017-06-07 Thread Rob Gaddi
On 06/06/2017 11:13 PM, Frank Millman wrote: Hi all It would be nice to write a generator in such a way that, in addition to 'yielding' each value, it performs some additional work and then 'returns' a final result at the end. From Python 3.3, anything 'returned&

  1   2   3   4   5   6   7   8   9   10   >