Re: [Tutor] pointers or references to variables or sub-sets of variables query.

2019-07-08 Thread bob gailer

Data = [

   ['2019-01-19','Fred Flintstone',23],
['2019-02-01','Scooby doo', 99]
]

Warning 3: age is not a fundamental attribute; it is a computed value!

--
Bob Gailer

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pointers or references to variables or sub-sets of variables query.

2019-07-08 Thread David L Neil

On 8/07/19 10:54 AM, Alan Gauld via Tutor wrote:

On 07/07/2019 20:54, David L Neil wrote:


(However, some of us grew-up at a time when RAM was expensive and even
in our relaxed state, such 'costs' still impinge on our consciousness -


Indeed, my first computer was at the local university and had 64KB.
My second computer was a Sinclair ZX81 (Timex in the USA?) with 16K


Wow, go you! I could never cope with using analog tape decks as digital 
storage devices.


I've just decided to take a look at SBCs. I guess the 'splash' of news 
about the Raspberry Pi 4 contributed to that, and yet also contributes 
to my prevarication/procrastination...


My 'first' was at high school - an over-grown accounting machine. 
Paper-tape program-software, Teletype-style input and 'line-flow' 
output, and a magnetic drum for data-storage (and yes, I was computing 
physical locations in order to optimise response times - try that!)


At uni, we built Motorola D2 Kits - IIRC an 8-bit Motorola MC6800 
processor. Maybe a 6809 - or more likely, that was the one to which we 
aspired. Those who could 'afford' more hardware courses started building 
intelligent devices, eg embedding a microprocessor within a 'dumb 
terminal'/'green screen'. Intelligent devices, Internet of Things. Plus 
ça change!




My third, a CP/M machine with 64K and 256K RAM disk and dual
floppies - such luxury! :-)


Ah nostalgia.

One of my divertissements of that era (early-80s) was MP/M - a bus 
network of what were effectively single-board processors. It implemented 
my first 'computer lab' and we taught everything from COBOL to 
accounting software and word processing on it. Fantastic stuff in its day!
(interestingly, my SBC research last night, took me to a R.Pi device 
embodying exactly these concepts: 
https://www.notebookcheck.net/Raspberry-Pi-Combine-a-Raspberry-Pi-with-up-to-4-Raspberry-Pi-Zeros-for-less-than-US-50-with-the-Cluster-HAT.426998.0.html)




So I agree, it is hard to get out of that mode of thinking. But
today the minimum RAM is typically 4GB or more. My desktop
boxes all have 16GB and even my ancient Netbook has 4G.
My 20 year old iBook has 640M and even that is enough to
run Python with many thousands of data objects instantiated.


particularly temporary, DB tables into MySQL's MEMORY storage (and with
almost zero code-change/risk)!


Yes, I use SQLite's MEMORY facility reguilarly. Not for managing
high volumes but where I need flexible search capability.
A SQL SELECT statement is much more flexible and faster
than any Python search I could cobble together.


(appreciating that I have no difficulty moving from (Python) procedural
programming to (SQL) declarative, but many of our colleagues hate such,
and with a passion)


Yes, I've never quite understood why some programmers are
reluctant to use SQL. For complex structured data it is by far the
simplest approach and usually very efficient, especially with big
volumes. But simple searches on small datasets are easier (or as easy)
in native Python.


Agreed, but if we move beyond standard dict-s, into multi-keyed data 
structures - even with PSL and PyPI at our disposal, isn't it 
much-of-a-muchness to use MySQL/SQLite versus linked-lists or trees?

(or perhaps am showing too much bias from personal experience?)

The "reluctance" (good word!) is intriguing: (a) one more 
package/language to learn - yet such claimants might well have been the 
ones leaping into NoSQL a few years back; and (b) it is a different way 
of thinking - compare 'spaghetti' and monolithic code to "structured", 
procedural to OOP, OOP to 'functional'... I notice a similar likelihood 
to avoid HTML/CSS because of their 'declarative' approaches.


Hey, if you don't like the green ones, that's all the more Smarties/M&Ms 
for me!
(also, avoid the brown ones, they may be 'sheep pellets'/rabbit 
droppings...)

--
Regards =dn
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pointers or references to variables or sub-sets of variables query.

2019-07-07 Thread Alan Gauld via Tutor
On 07/07/2019 20:54, David L Neil wrote:

> (However, some of us grew-up at a time when RAM was expensive and even 
> in our relaxed state, such 'costs' still impinge on our consciousness - 

Indeed, my first computer was at the local university and had 64KB.

My second computer was a Sinclair ZX81 (Timex in the USA?) with 16K

My third, a CP/M machine with 64K and 256K RAM disk and dual
floppies - such luxury! :-)

So I agree, it is hard to get out of that mode of thinking. But
today the minimum RAM is typically 4GB or more. My desktop
boxes all have 16GB and even my ancient Netbook has 4G.
My 20 year old iBook has 640M and even that is enough to
run Python with many thousands of data objects instantiated.

> particularly temporary, DB tables into MySQL's MEMORY storage (and with 
> almost zero code-change/risk)!

Yes, I use SQLite's MEMORY facility reguilarly. Not for managing
high volumes but where I need flexible search capability.
A SQL SELECT statement is much more flexible and faster
than any Python search I could cobble together.

> (appreciating that I have no difficulty moving from (Python) procedural 
> programming to (SQL) declarative, but many of our colleagues hate such, 
> and with a passion)

Yes, I've never quite understood why some programmers are
reluctant to use SQL. For complex structured data it is by far the
simplest approach and usually very efficient, especially with big
volumes. But simple searches on small datasets are easier (or as easy)
in native Python.

-- 
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


Re: [Tutor] pointers or references to variables or sub-sets of variables query.

2019-07-07 Thread David L Neil

On 8/07/19 2:48 AM, Alan Gauld via Tutor wrote:

On 07/07/2019 09:19, David L Neil wrote:

First-off, it has to be said that "100's of elements" suggests using an
RDBMS - particularly if 'age' (eg 23 and 99) is not the only likely
selection mechanism.


Multiple selection mechanisms might suggest an RDBMS but hundreds of
items is chickenfeed and an RDBMS would be overkill for such small
numbers, if volume was the only criteria. Millions of items would
certainly warrant such an approach but nowadays holding 10's of
thousands of items in memory is entirely reasonable.



Assuming plentiful RAM: agreed.
(However, some of us grew-up at a time when RAM was expensive and even 
in our relaxed state, such 'costs' still impinge on our consciousness - 
also, in another thread (here?Python list) we had someone frustrated 
about using an MS-Vista 'powered' machine and limited to 32-bits. We 
don't know the OP's circumstances. That said, loading an RDBMS, if (s)he 
doesn't already have one, is...)


As you point-out, with memory more-commonly available, I've obtained 
significant speed improvements by moving relatively small, and 
particularly temporary, DB tables into MySQL's MEMORY storage (and with 
almost zero code-change/risk)!

(so, it IS possible to teach old dogs new tricks)


The key justification for moving to RDBMS would be "not the only 
selection mechanism". Whereas a Python dictionary (hash) offers speedy 
access to data based upon a single index, it is hard to beat the bug- 
and time-saving facility of a DB managing multiple indices/indexes.
(appreciating that I have no difficulty moving from (Python) procedural 
programming to (SQL) declarative, but many of our colleagues hate such, 
and with a passion)



So, using the OP's data-example, and assuming the 'columns' to be 
perhaps employment_date, name, and age; respectively:


['2019-01-19','Fred Flintstone',23],
['2019-02-01','Scooby doo', 99]

- which Python (and pythonic - per OP's theme) structures and methods 
offer a relatively bug-unlikely solution to holding *multiple* indices 
into a base list (or other collection)?
(alternately, maybe we should wait for the OP, and allow opportunity to 
complete the homework first?)


(NB this may be veering OT, if the OP requires only the single access 
method, such as that illustrated earlier)

--
Regards =dn
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pointers or references to variables or sub-sets of variables query.

2019-07-07 Thread Mats Wichmann
On 7/6/19 8:39 PM, mhysnm1...@gmail.com wrote:
> Hi all.
> 
> In C, you can use pointers to reference variables, arrays, ETC. In python, I
> do not recall anything specifically that refers to such a capability. What I
> want to do is:
> 
> I want to create different data structures such as dictionaries which
> contain specific  list elements based upon specific keys. The original data
> structure could look like:
> 
> Data = [
>   ['2019-01-19','Fred Flintstone',23],
>   ['2019-02-01','Scooby doo', 99]
> ]
> 
> The above structure does have 100's of elements. I want to reference
> specific lists within the above structure. Using the only method I know how:
> 
> Category = {'under-50':[data[0]], 'over-50':[data[1]]}
> 
> If I understand things correctly with Python. The above will copy the value
> into the list within the key. Not the memory address of the nested list I am
> referencing. I am using a list within the key to permit multiple references
> to different nested lists from the original data structure. The end result
> of the structure for the dict could look like this (using example, not real
> output)
> 
> Category['under-50'] = [ List1 pointer, List22 pointer, List52 pointer]
> 
> I hope the above makes sense. How can this be done? 

It's easy enough to convince yourself that what Alan said is true. You
can, for example, use the id function to show this:

https://docs.python.org/3/library/functions.html#id

# identity of 0'th element of Data:
print(id(Data[0]))
# identity of the list that is the value of 'under-50' key:
print(id(Category['under-50']))
# identity of 0'th element of that list:
print(id(Category['under-50'][0])

the first and third should be the same, showing you that's the same
object referred to by those two places.  Again, like Python's
"variables", these are just references to objects. As in:

item = Data[0]
print(id(item), id(Data[0]))

(note: id() is handy for explorations, especially interactive ones, but
isn't terribly useful for production code.  don't attach any meaning to
the value returned by id() other than "unique" - different Pythons
famously generate different id values, something that's been known to
confuse people doing experiments in, for example, PyPy)

Since you turned up here you sometimes also get free unasked-for advice:
I know this was a toy fragment just to explain the concept you're
getting at, but you'll normally want to build your design in a way that
minimizes "magic".  Using numbered indices into an array-like structure
is one of those bits of magic that raises flags. To refer to Fred's age,
you could end up with  Data[0][2].  That would be pretty ugly, and
worse, hard to remember what it meant.  Try to seek ways you can give
meaningful names to things.  We can make suggestions if that's of
interest (I don't want to belabor the point).
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pointers or references to variables or sub-sets of variables query.

2019-07-07 Thread Alan Gauld via Tutor
On 07/07/2019 09:19, David L Neil wrote:
> First-off, it has to be said that "100's of elements" suggests using an 
> RDBMS - particularly if 'age' (eg 23 and 99) is not the only likely 
> selection mechanism.

Multiple selection mechanisms might suggest an RDBMS but hundreds of
items is chickenfeed and an RDBMS would be overkill for such small
numbers, if volume was the only criteria. Millions of items would
certainly warrant such an approach but nowadays holding 10's of
thousands of items in memory is entirely reasonable.

-- 
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


Re: [Tutor] pointers or references to variables or sub-sets of variables query.

2019-07-07 Thread David L Neil
First-off, it has to be said that "100's of elements" suggests using an 
RDBMS - particularly if 'age' (eg 23 and 99) is not the only likely 
selection mechanism.



On 7/07/19 2:39 PM, mhysnm1...@gmail.com wrote:

Hi all.
In C, you can use pointers to reference variables, arrays, ETC. In python, I
do not recall anything specifically that refers to such a capability. What I
want to do is:


Just because C has a construct does not imply that it does, nor even 
should, exist in another language! You're using Python because it is 
'better', right?


You are correct, Python does not use "pointers", and (a personal 
comment) I for one don't miss them and their many 'gotchas', eg 
out-by-one errors, preferring Python's constructs, eg for-each.


That said, Python's sequences (data structures, eg strings and lists) do 
offer indices, slicing, and striding. So, it is quite possible to 
(relatively) address the first item in a list as list_item[ 0 ]. You can 
read about these (and many other delights) in the docs...




I want to create different data structures such as dictionaries which
contain specific  list elements based upon specific keys. The original data
structure could look like:
Data = [
   ['2019-01-19','Fred Flintstone',23],
['2019-02-01','Scooby doo', 99]
]


Warning1: seem to be missing any identification of the "key"
Warning2: the intro text talked about "dictionaries" (the correct word) 
but the code-snippet is describing nested lists




The above structure does have 100's of elements. I want to reference
specific lists within the above structure. Using the only method I know how:

Category = {'under-50':[data[0]], 'over-50':[data[1]]}

If I understand things correctly with Python. The above will copy the value
into the list within the key. Not the memory address of the nested list I am
referencing. I am using a list within the key to permit multiple references
to different nested lists from the original data structure. The end result
of the structure for the dict could look like this (using example, not real
output)

Category['under-50'] = [ List1 pointer, List22 pointer, List52 pointer]

I hope the above makes sense. How can this be done?


I hope I've understood the description! One option would be to follow 
your line of thinking by turning the first data-structure into a 
dictionary (key-value) pairs, where the key is the character's age and 
the value is the inner list structure, previously outlined:


{
  23: ['2019-01-19','Fred Flintstone',23],
  99: ['2019-02-01','Scooby doo', 99]
}

Then it would be possible to maintain the two lists, each containing 
keys for the relevant dict-elements:


under_50 = [ 23 ]
over_50 = [ 99 ]

However, this would require that only one character be listed at a given 
age (dict keys must be unique), so another key might be a better choice!



Another data structure you might consider is a "linked list".

--
Regards =dn
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pointers or references to variables or sub-sets of variables query.

2019-07-07 Thread Alan Gauld via Tutor
On 07/07/2019 03:39, mhysnm1...@gmail.com wrote:

> In C, you can use pointers to reference variables, arrays, ETC. In python, I
> do not recall anything specifically that refers to such a capability.

In Python a variable is a name that refers to an object.
Many names can refer to the same object. So in that respect
Python variables are more like pointers than regular C
variables which are a named location in memory.

> Data = [
>   ['2019-01-19','Fred Flintstone',23],
>   ['2019-02-01','Scooby doo', 99]
> ]
> 
> 
> Category = {'under-50':[data[0]], 'over-50':[data[1]]}
> 
> If I understand things correctly with Python. The above will copy the value
> into the list within the key.

No, that is not correct.
It will create a reference to the same data object

So Category['under-50'][0] and Data[0] will both reference
the same list object. Modifying the data through either
variable will affect both because it will be the same
list being modified.

>  Not the memory address of the nested list I am
> referencing. 

It is best to forget all about memory addresses when thinking
about Python. They are irrelevant for the most part..

> Category['under-50'] = [ List1 pointer, List22 pointer, List52 pointer]

That is exactly what happens in Python, as standard.

The usual issue that people have with this is that they modify
the data in one place and are surprised to discover it has
been modified elsewhere too. If that is a problem then you must
explicitly create a copy. But the behaviour that you apparently
want is the default.

-- 
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


Re: [Tutor] Pointers in python ??

2008-01-20 Thread Alan Gauld
"Michael H. Goldwasser" <[EMAIL PROTECTED]> wrote

>>It does have the concept of C++ references however and in fact
>>thats how Pyhon variables work. They are all references.

> However I strongly disagree with your suggestion that Python's
> variables work like C++ reference variables.

You are quite correct, I overstated the similarity, especially
in saying that they "work like" C++ references. I was really
only refering to the fact that in both cases the references
are to other variables/objects rather than to memory
locations. But the underlying semantics are quite different.

> reference variable must be initially bound to an existing object and
> that association cannot henceforth be changed.

But I had actually forgotten that references could not be reassigned.
My C++ is pretty rusty, I haven't used C++ much in the last 7
or 8 years! :-)

Thanks for the clarification Michael.

Alan G. 


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pointers in python ??

2008-01-20 Thread Michael H. Goldwasser

On Sunday January 20, 2008, Alan Gauld wrote: 

>"Varsha Purohit" <[EMAIL PROTECTED]> wrote
>
>>Does python has concept of pointers like c/cpp ?? If yes 
>> how.. can
>> anyone give me a small example to how we can use pointers in python.
>
>No, not really.
>
>It does have the concept of C++ references however and in fact
>thats how Pyhon variables work. They are all references. But
>there is no real concept of a poibnter to a specific memory
>location, and especially one that can be manipulated
>arithmetically.

You are correct in that Python has no concept of pointer arithmetic or
any direct access of memory based on a pointer value.

However I strongly disagree with your suggestion that Python's
variables work like C++ reference variables.  The issue is that a C++
reference variable must be initially bound to an existing object and
that association cannot henceforth be changed.  Consider the following
C++ example, presuming that we have a basic Point class (not shown
here).

Point a(0,0);
Point b(5,7);
Point& c = a; // C++ reference variable

At this point there are two instances.  The names a and c are bound to
the same underlying instance and b is bound to a second instance.
Consider the following

c = b;   // reassigns the VALUE of c (aka a) to 5,7 but c is still bound to 
a
c.setX(3);   // notice that this has no effect on b;  c is not bound to b
cout << a;   // would output <3,7>
cout << b;   // would output <5,7>
cout << c;   // would output <3,7>

Translating these same seven command into Python would produce
different results, most notably because of the c=b assignment.

C++ When passing a parameter as a C++ reference, similar semantics are
used. The formal parameter is bound to the actual parameter upon
invocation of a function and from that point on assignments within the
body do not rebind the name but instead alter the value of the
underlying instance.

bool clear(Point& p) {
  p = Point(0,0);// changes the actual parameter's value
}

As a final issue, notice that a C++ pointer can be assigned to null,
just as a Python variable can be assigned to None.  (C++ reference
variable cannot be null).

I should say that the SYNTAX of C++ pointers are different, as you
need to explicitly dereference them to access the underlying instance,
as in c->setX(3) rather than c.setX(3).

If you are comfortable with Java's syntax and semantics, it is easy to
explain.  The model for all data types in Python is the same as the
model used for non-primitive types in Java.

With regard,
Michael


   +---
   | Michael Goldwasser
   | Associate Professor
   | Dept. Mathematics and Computer Science
   | Saint Louis University
   | 220 North Grand Blvd.
   | St. Louis, MO 63103-2007

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pointers

2006-01-11 Thread Danny Yoo


On Wed, 11 Jan 2006, Burge Kurt wrote:

> I f I want to translate C code to Python and have a function like
>
> void get_args(int argc, char* argv[], Argument* args)
> {


Hi Burge,

Also wanted to note that the Standard Library already contains an
argument-parsing library, so you may want to take advantage of it.  The
library is called 'optparse':

http://python.org/doc/lib/module-optparse.html

It's something to keep in mind, just in case during your porting effort
you have the freedom to reuse the Standard Library.

Good luck!

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pointers

2006-01-11 Thread w chun
On 1/11/06, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Burge Kurt wrote:
> >
> > void get_args(int argc, char* argv[], Argument* args)
> >
> > My first question about the pointers here; how can I convert them to
> > Python?
>
> Python doesn't have pointers in the sense of direct references to
> memory. Python has very good built in support for higher-level
> structures than C has. Strings and lists are both built in.

the main reason why pointers are used in C (and C++) is so that the
called function has the ability to modify the object (since it is
passed by reference).

in Python, references to objects passed in are also "live," meaning
that if it is a mutable (modifiable) object, you can manipulate it
directly without using the asterisk/star (*).

in bernard's example, we've replaced char* argv[] as an argument to
main by doing an import of sys and using the argv attribute of the sys
module, i.e., sys.argv.  to access individual arguments, you would
replace something like:

for (int i = 0; i < argc; i++) {
:
... argv[i] ...
:
}

... with ...

for i in range(len(sys.argv)):
:
... sys.argv[i] ...
:

... or ...

for eachArg in sys.argv:
:
... eachArg ...
:


> I'll guess that Argument* args is a pointer to an array of Argument
> objects. In Python this would be represented by a list of Argument objects.

it looks like it's a set of variable arguments (varargs).  Python has
support for this too, and it's one of the rare places you will see
asterisks (*) used.

we replace "void get_args(int argc, char* argv[], Argument* args)"
with "def get_args(*args)".  (recall that argv is sys.argv and argc is
len(sys.argv).)  then to access each extra argument, you would:

for eachArg in args:
   :
... eachArg ...

hope this helps!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2006,2001
http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pointers

2006-01-11 Thread Kent Johnson
Burge Kurt wrote:
> Sorry for the previous message I did it by mistake..
> the function was like below:
>  
> void get_args(int argc, char* argv[], Argument* args)
> {
> //check the amount of the arguments
> if(argc%2 == 0)
>{
>printf("Error, incorrect argument numbers : %d\n",argc);
>print_help();
>exit(1);
> }
>
> .
> .
> }
>  
> My first question about the pointers here; how can I convert them to 
> Python?

Python doesn't have pointers in the sense of direct references to 
memory. Python has very good built in support for higher-level 
structures than C has. Strings and lists are both built in.

As Bernard has pointed out, where a C function might have a count (argc) 
and a pointer to an array of pointers to strings (char* argv[]), Python 
uses just a list of strings.

I'll guess that Argument* args is a pointer to an array of Argument 
objects. In Python this would be represented by a list of Argument objects.

Use of lists and strings should be covered in any introductory Python 
tutorial or book; you might find one you like here:
http://wiki.python.org/moin/BeginnersGuide/NonProgrammers
http://wiki.python.org/moin/IntroductoryBooks

Kent

>  
> And second and may be a little stupid; do I need to define argc how can 
> I get arguments in python ?
>  
> Thanks in advance,
>  
> Burge
> 
> 
> 
> 
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pointers

2006-01-11 Thread Bernard Lebel
Hi Burge,

You can access command line argument via sys.argv:

import sys
print sys.argv

This prints a list of the command line arguments. Since argv is a
list, it means you can check its length to get the argument count:

print len( sys.argv )

There is always at least one argument in this list, if no argument was
supplied, then you get an empty string.


Hope this helps
Bernard



On 1/11/06, Burge Kurt <[EMAIL PROTECTED]> wrote:
> Sorry for the previous message I did it by mistake..
> the function was like below:
>
> void get_args(int argc, char* argv[], Argument* args)
> {
> //check the amount of the arguments
> if(argc%2 == 0)
>{
>printf("Error, incorrect argument numbers : %d\n",argc);
>print_help();
>exit(1);
> }
>
> .
> .
> }
>
> My first question about the pointers here; how can I convert them to Python?
>
> And second and may be a little stupid; do I need to define argc how can I
> get arguments in python ?
>
> Thanks in advance,
>
> Burge
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pointers

2006-01-11 Thread Burge Kurt
Sorry for the previous message I did it by mistake..the function was like below:
 
void get_args(int argc, char* argv[], Argument* args){    //check the amount of the arguments    if(argc%2 == 0)
   {   printf("Error, incorrect argument numbers : %d\n",argc);       print_help();   exit(1);    }    
.
.
}
 
My first question about the pointers here; how can I convert them to Python? 
 
And second and may be a little stupid; do I need to define argc how can I get arguments in python ?
 
Thanks in advance,
 
Burge
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor